Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vince-fugnitto/067de47f23b2326fb1da9827d8ed02ed to your computer and use it in GitHub Desktop.
Save vince-fugnitto/067de47f23b2326fb1da9827d8ed02ed to your computer and use it in GitHub Desktop.
$env:API_TOKEN="<replace>" # https://ci.appveyor.com/api-keys
$env:APPVEYOR_ACCOUNT_NAME="<replace>" # from AppVeyor URL (after "project/")
$env:APPVEYOR_PROJECT_SLUG="<replace>" # from AppVeyor URL (after account name)
$env:recordsNumber = 20
$headers = @{
"Authorization" = "Bearer $env:API_TOKEN"
"Content-type" = "application/json"
}
$history=Invoke-RestMethod -Uri "https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=$env:recordsNumber" -Headers $headers -Method Get
$queued = $history.builds | ? {$_.status -eq "queued"}
$queued | % {
Write-Host "Cancelling build version $($_.version)"
Invoke-RestMethod -Uri "https://ci.appveyor.com/api/builds/$($env:APPVEYOR_ACCOUNT_NAME)/$($env:APPVEYOR_PROJECT_SLUG)/$($_.version)" -Headers $headers -Method Delete
Write-Host "Deleting build version $($_.version)"
Invoke-RestMethod -Uri "https://ci.appveyor.com/api/builds/$($_.buildId)" -Headers $headers -Method Delete
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment