Skip to content

Instantly share code, notes, and snippets.

@IlyaFinkelshteyn
Created December 1, 2017 03:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IlyaFinkelshteyn/dc0b08593cb0babff2bd84dd05c4ee42 to your computer and use it in GitHub Desktop.
Save IlyaFinkelshteyn/dc0b08593cb0babff2bd84dd05c4ee42 to your computer and use it in GitHub Desktop.
if ($env:APPVEYOR_JOB_NUMBER -ne 1) {return}
write-host "Waiting for other jobs to complete"
$headers = @{
"Authorization" = "Bearer $ApiKey"
"Content-type" = "application/json"
}
[datetime]$stop = ([datetime]::Now).AddMinutes($env:TimeOutMins)
[bool]$success = $false
while(!$success -and ([datetime]::Now) -lt $stop) {
$project = Invoke-RestMethod -Uri "https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG" -Headers $headers -Method GET
$success = $true
$project.build.jobs | foreach-object {if (($_.jobId -ne $env:APPVEYOR_JOB_ID) -and ($_.status -ne "success")) {$success = $false}; $_.jobId; $_.status}
if (!$success) {Start-sleep 5}
}
if (!$success) {throw "Test jobs were not finished in $env:TimeOutMins minutes"}
@IlyaFinkelshteyn
Copy link
Author

@jezzsantos sorry missed this question. Please check conditional deployment

@splatteredbits
Copy link

This doesn't work if you've got two builds running at the same time. Only the most recent build is ever returned. So, it doesn't work if you're doing a branch build and a PR build at the same time.

I would expect the https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG endpoint to return all running builds, but it only returns the one with the highest build number. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment