Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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 "$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG" -Headers $headers -Method GET
$success = $true
$ | 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"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment