Created
May 5, 2017 00:34
-
-
Save slamb2k/b08af2eee344d92947c71357c6988864 to your computer and use it in GitHub Desktop.
VSMobileCenterBuildWait
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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