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 Ascendon/job/${bamboo.planRepository.branch}/lastBuild/api/jsonIf ($res.StatusCode -ne 200) { # build not found exit 1}$data = $res.Content | ConvertFrom-JsonIf ($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
It looks like you're new here. Sign in or register to get started.