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

adriana.oliva.remola's Avatar

adriana.oliva.remola

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:
https://help.appveyor.com/discussions/questions/5016-skip-scheduled-build-with-same-commit-id-as-previous-build

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"
    }
    $apiURL = "$env:APPVEYOR_URL/project/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG"
    $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
      $history.builds[1].commitId
      if ($CurrentCommitID -eq $PreviousCommitID)
      {
        Write-host "Current Commit ID is the same as previous, exiting build."
        Exit-AppveyorBuild
      }
    }
    
    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

Generic

? 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

Recent Discussions

27 Jan, 2023 08:06 PM
27 Jan, 2023 08:05 PM
25 Jan, 2023 03:23 PM
25 Jan, 2023 03:22 PM
23 Jan, 2023 03:29 PM