Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save IlyaFinkelshteyn/26be0b5e7e10a684bc7e2c1ae94c0fbf to your computer and use it in GitHub Desktop.
Save IlyaFinkelshteyn/26be0b5e7e10a684bc7e2c1ae94c0fbf to your computer and use it in GitHub Desktop.
$token="<Your_api_token>"
$accountName="<Your_account>"
$projectSlug="<Your_project_slug>"
$toFind = @("foo", "bar")
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}
$body = @{
accountName=$accountName
projectSlug=$projectSlug
}
$body = $body | ConvertTo-Json
$newBuild = Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/builds' -Headers $headers -Body $body -Method POST
$jobId = (Invoke-RestMethod -Uri "https://ci.appveyor.com/api/projects/$accountName/$projectSlug/build/$($newBuild.version)" -Headers $headers -Method GET).build.jobs[0].jobId
$status = "running";
$found = $false
while(($status -eq "running") -and ($found -eq $false)) {
try {$log = Invoke-RestMethod -Uri "https://ci.appveyor.com/api/buildjobs/$jobId/log" -Headers $headers -Method GET} catch {}
if ($log) {
$found = $true
$toFind | % {if(!$log.Contains($_)) {$found = $false}}
$status = (Invoke-RestMethod -Uri "https://ci.appveyor.com/api/projects/$accountName/$projectSlug/build/$($newBuild.version)" -Headers $headers -Method GET).build.status
write-host "Status: $status"
write-host "Found: $found"
if ($found) { $toFind | % {$log | findstr /psi $_}}
}
sleep 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment