From 80646fe9432356cd0204ef5377a2a69a2d759200 Mon Sep 17 00:00:00 2001 From: Zelin Wang Date: Fri, 26 Jun 2026 17:12:12 +1000 Subject: [PATCH] Switch docs reference trigger from branch to tag trigger --- .../trigger-reference-docs-ci.yml | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/.azure-pipelines/trigger-reference-docs-ci.yml b/.azure-pipelines/trigger-reference-docs-ci.yml index 3c3ca499721..9f3d6eecb19 100644 --- a/.azure-pipelines/trigger-reference-docs-ci.yml +++ b/.azure-pipelines/trigger-reference-docs-ci.yml @@ -2,10 +2,11 @@ name: Azure CLI Trigger Reference Docs CI trigger: branches: + exclude: + - '*' + tags: include: - - release - - release-lts-* - - test-release-* + - azure-cli-* pr: none @@ -19,7 +20,6 @@ variables: jobs: - job: TriggerReferenceDocsCI displayName: 'Queue Microsoft Learn Docs Reference CI' - condition: or(eq(variables['Build.SourceBranchName'], 'release'), startsWith(variables['Build.SourceBranchName'], 'release-lts-'), startsWith(variables['Build.SourceBranchName'], 'test-release-')) pool: name: ${{ variables.ubuntu_pool }} steps: @@ -35,7 +35,28 @@ jobs: $project = $env:AdoProject $thisRepoLink = $env:ThisRepoLink $thisRunLink = $env:ThisRunLink - $triggerBranch = $env:ReleaseBranch + $tagName = $env:TagName + + # Resolve the release's target_commitish ('release' = latest, 'release-lts-' = LTS) to pick + # the matching docs pipeline. Never guess: retry transient errors, but a 404 (tag with no Release) + # or exhausted retries fail the job so a release is never queued against the wrong pipeline. + $triggerBranch = $null + for ($attempt = 1; $attempt -le 3; $attempt++) { + $resp = Invoke-WebRequest -Uri "https://api.github.com/repos/Azure/azure-cli/releases/tags/$tagName" -Headers @{ 'User-Agent' = 'azure-cli-ado' } -SkipHttpErrorCheck + if ($resp.StatusCode -ge 200 -and $resp.StatusCode -lt 300) { + $triggerBranch = ($resp.Content | ConvertFrom-Json).target_commitish + break + } + if ($resp.StatusCode -eq 404) { + throw "Tag '$tagName' has no GitHub Release (404); aborting without queuing." + } + Write-Host "Release lookup attempt $attempt got HTTP $($resp.StatusCode), retrying..." + Start-Sleep -Seconds 10 + } + if (-not $triggerBranch) { + throw "Could not resolve target_commitish for tag '$tagName' after retries; aborting." + } + $definitionId = $triggerBranch -like 'release-lts-*' ? $env:AdoLtsPipelineId : $env:AdoLatestPipelineId $variables = @("triggerBranch=$triggerBranch", "triggerFromRepo=$thisRepoLink", "triggerByPipeline=$thisRunLink") @@ -53,6 +74,6 @@ jobs: AdoProject: $(ADO_DocsReference_Project) AdoLatestPipelineId: $(ADO_DocsReference_Latest_Pipeline_ID) AdoLtsPipelineId: $(ADO_DocsReference_LTS_Pipeline_ID) - ReleaseBranch: $(Build.SourceBranchName) + TagName: $(Build.SourceBranchName) ThisRepoLink: $(Build.Repository.Uri) ThisRunLink: $(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)