skip scheduled build with same commit id as previous build - configure it in

adriana.oliva.remola's Avatar


22 May, 2020 09:57 AM

I am trying to configure to cancel a scheduled build if the Commit ID is equal as the previous build, something similar as the post:

but I don't know how to implement it.

I want to define it directly on the UI in the "init script" without the need of calling any external file.

Is there any way to do it?

  1. 1 Posted by adriana.oliva.r... on 22 May, 2020 12:26 PM

    adriana.oliva.remola's Avatar

    What I have configured so far is in AppVeyor UI / Environment / init script:

    $headers = @{
      "Authorization" = "Bearer $token"
      "Content-type" = "application/json"
    $history = Invoke-RestMethod -Uri "$apiURL/history?recordsNumber=2" -Headers $headers  -Method Get
    Write-host $apiURL
    Write-Host $history.builds.Count
    if ($history.builds.Count -eq 2)
      $CurrentCommitID = $history.builds[0].commitId
      Write-host $CurrentCommitID
      $PreviousCommitID = $history.builds[1].commitId
      Write-host $PreviousCommitID
      if ($CurrentCommitID -eq $PreviousCommitID)
        Write-host "Current Commit ID is the same as previous, exiting build."
    defining the AppVeyor Token as a secure variable and the outcome that I get so far is:
    • API URL: http://localhost/project/AppVeyor/appveyor-t2

    • History Build Count: 0

    As History Build Count is 0, it does not enter into the if statement.

    It seems that the history records are not being get properly. Any idea why?

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac