I'm trying to set up a task that will make repeated http requests until I get the result I'm looking for (something like "build finished")
I'm using Powershell Invoke-WebRequest to attempt this, but I haven't figured out a way to have my task repeat as needed.
Here's the script I'm using. I'd appreciate any help I can get!
$res = Invoke-WebRequest http://jenkins-svrnd-asc:8080/jenkins/job/New%20Ascendon/job/${bamboo.planRepository.branch}/lastBuild/api/json
If ($res.StatusCode -ne 200) {
# build not found
exit 1
}
$data = $res.Content | ConvertFrom-Json
If ($data.building) {
# re-run this task
exit 1
} Else {
If ($data.result -eq 'SUCCESS') {
# go to next step
exit 0
} ElseIf ($data.result -eq 'FAILURE') {
# drop out to failure step
exit 1
} ElseIf ($data.result -eq 'UNSTABLE') {
# drop out to failure step
exit 1
}
}
Hi,
Thanks for your question!
First of all, I am not a Windows PowerShell expert so please excuse me for very generic response. But logically how about using a while loop to continuously look for the result and then based on the found condition set the counter (as true or false) to exit the loop?
Let me know if it makes sense, or I will try to implement it in Bash.
Thanks,
Robhit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.