Skip to content

Instantly share code, notes, and snippets.

@slamb2k

slamb2k/wait.js

Created May 5, 2017
Embed
What would you like to do?
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
You can’t perform that action at this time.