Skip to content

Instantly share code, notes, and snippets.

@slamb2k
Created May 5, 2017 00:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slamb2k/714a934c2e8e5cac21f47691cd81af74 to your computer and use it in GitHub Desktop.
Save slamb2k/714a934c2e8e5cac21f47691cd81af74 to your computer and use it in GitHub Desktop.
VSMobileCenterBuildConnection
/*
* Retrieves the details from the service endpoint defined for Mobile Center in VSTS
*/
function getMobileCenterEndpointDetails(endpointInputFieldName) {
'use strict';
var errorMessage = "Can't decode endpoint.";
var endpoint = tl.getInput(endpointInputFieldName, true);
console.log(`Endpoint: ${endpoint}`);
if (!endpoint) {
throw new Error(errorMessage);
}
let url = tl.getEndpointUrl(endpoint, false);
console.log(`URL: ${url}`);
let apiServer = url.substr(0, url.lastIndexOf('/'));
console.log(`API Server: ${apiServer}`);
let apiVersion = url.substr(url.lastIndexOf('/') + 1);
console.log(`API Version: ${apiVersion}`);
var authToken = tl.getEndpointAuthorizationParameter(endpoint, 'apitoken', false);
if (!authToken)
{
console.log("NO AUTHTOKEN");
}
return {
apiServer: apiServer,
apiVersion: apiVersion,
authToken: authToken
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment