Last active
September 13, 2019 12:33
-
-
Save IlyaFinkelshteyn/ec6c13c31d9b16ff0d262818540bd407 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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