tag:help.appveyor.com,2012-11-13:/discussions/questions/48398-skip-scheduled-build-with-same-commit-id-as-previous-build-configure-it-inAppVeyor: Discussion 2020-05-22T12:26:41Ztag:help.appveyor.com,2012-11-13:Comment/483542392020-05-22T12:26:40Z2020-05-22T12:26:41Zskip scheduled build with same commit id as previous build - configure it in <div><p>What I have configured so far is in AppVeyor UI / Environment / init script:<br></p>
<pre>
<code>$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
}
}</code>
</pre>
defining the AppVeyor Token as a secure variable and the outcome that I get so far is:
<ul>
<li>
<p>API URL: http://localhost/project/AppVeyor/appveyor-t2</p>
</li>
<li>
<p>History Build Count: 0</p>
</li>
</ul>
<p>As History Build Count is 0, it does not enter into the if statement.</p>
<p>It seems that the history records are not being get properly. Any idea why?</p></div>adriana.oliva.remola