Skip to content

Commit c356f6d

Browse files
committed
Updating Publish to cancel builds with ***NO_CI***
1 parent f197d5f commit c356f6d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

.ado/publish.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ jobs:
9595
cancelTimeoutInMinutes: 5
9696
steps:
9797
- powershell: |
98-
Write-Error "Stopping because commit message contains ***NO_CI***."
98+
Write-Host "Stopping because commit message contains ***NO_CI***."
99+
$uri = "https://dev.azure.com/microsoft/ReactNative/_apis/build/builds/$(Build.BuildId)?api-version=5.1"
100+
$json = @{status="Cancelling"} | ConvertTo-Json -Compress
101+
$build = Invoke-RestMethod -Uri $uri -Method Patch -Headers @{Authorization = "Bearer $(System.AccessToken)"} -ContentType "application/json" -Body $json
102+
Write-Host $build
103+
Write-Host "Waiting 60 seconds for build cancellation..."
104+
Start-Sleep -Seconds 60
99105
displayName: Stop pipeline if latest commit message contains ***NO_CI***
100106
condition: and(${{ parameters.stopOnNoCI }}, contains(variables['Build.SourceVersionMessage'], '***NO_CI***'))
101107

0 commit comments

Comments
 (0)