Skip to content

Instantly share code, notes, and snippets.

@slamb2k
Created May 5, 2017 00:34
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/b08af2eee344d92947c71357c6988864 to your computer and use it in GitHub Desktop.
Save slamb2k/b08af2eee344d92947c71357c6988864 to your computer and use it in GitHub Desktop.
VSMobileCenterBuildWait
function waitForCompletion(buildId) {
return Q.delay(waitTime * 1000)
.then(function () {
return checkForCompletion(buildId)
})
.then(function (finished) {
return finished === true ? buildId : waitForCompletion(buildId);
});
}
function checkForCompletion(buildId) {
util.debug("Getting build detail for Build Id: {0}", buildId);
// Construct build definition Url
var buildDetailUrl = `${mobileCenterBaseUrl}/builds/${buildId}`;
var options = {
url: buildDetailUrl,
headers: {
"X-API-Token": apiToken,
"Accept": "application/json",
"Content-Type": "application/json"
}
};
return request(options)
.then(function (body) {
// Parse the response so we can get the build detail
var buildDetail = JSON.parse(body);
util.debug("Current build status: {0}", buildDetail.status);
return (buildDetail.status === "completed");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment