Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# $env:API_KEY should be defined as a secure variable
$headers = @{
"Authorization" = "$env:API_KEY"
"Content-type" = "application/json"
$history = Invoke-RestMethod -Uri "$apiURL/history?recordsNumber=5" -Headers $headers -Method Get
if ($history.builds.Count -eq 5)
$previousBuild = $history.builds | ? {($_.commitId -eq $env:APPVEYOR_REPO_COMMIT) -and ($_.buildId -ne $env:APPVEYOR_BUILD_ID)} | Sort-Object -Property created -Descending | Select-Object -First 1
if ($previousBuild) {
if ($previousBuild.status -eq "success") {
Write-Host "Commit $env:APPVEYOR_REPO_COMMIT was already built with success"
elseif ($previousBuild.status -eq "failed") {
Throw "Commit $env:APPVEYOR_REPO_COMMIT was already already built with failure"
else {
Write-Host "Commit $env:APPVEYOR_REPO_COMMIT was already built, but without either success or failure, continuing..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.