skip scheduled build with same commit id as previous build

mamo's Avatar


26 Jun, 2017 08:45 PM


Is there a way to skip a scheduled build if the commit id is the same commit id as the previous build?


  1. 1 Posted by mamo on 26 Jun, 2017 09:21 PM

    mamo's Avatar

    It looks like I can use
    GET /api/projects/{accountName}/{projectSlug} to get the last build in a before_build and cancel the build build with DELETE /api/builds/{accountName}/{projectSlug}/{buildVersion} if the commit id is the same.

  2. 2 Posted by Ilya Finkelshte... on 26 Jun, 2017 09:26 PM

    Ilya Finkelshteyn's Avatar

    Right, also you can exit build with success with appveyor exit or Exit-AppveyorBuild as described here

  3. 3 Posted by mamo on 26 Jun, 2017 09:54 PM

    mamo's Avatar

    Thanks for the quick response. I'll use those exit commands.

  4. 4 Posted by richard.thomas8... on 08 Aug, 2017 01:38 PM

    richard.thomas86's Avatar

    Any chance you could post the snippet for that before_build script? I'm trying to achieve the same thing and haven't figured a way to do it properly.

  5. 5 Posted by Ilya Finkelshte... on 08 Aug, 2017 07:14 PM

    Ilya Finkelshteyn's Avatar

    Here you go:

    $headers = @{
      "Authorization" = "Bearer $token"
      "Content-type" = "application/json"
    $history = Invoke-RestMethod -Uri "$apiURL/history?recordsNumber=2" -Headers $headers  -Method Get
    if ($history.builds.Count -eq 2)
      $CurrentCommitID = $history.builds[0].commitId
      $PreviousCommitID = $history.builds[1].commitId
      Write-host "Current Commit ID: $CurrentCommitID"
      Write-host "Previous Commit ID: $PreviousCommitID"
      if ($CurrentCommitID -eq $PreviousCommitID)
        Write-host "Current Commit ID is the same as previous, exiting build."

    UPDATE: you can add this as early as init stage.
    UPDATE2: $token is AppVeyor API token, add it as a secure variable

  6. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:18 AM.

Comments are currently closed for this discussion. You can start a new one.

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