Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions .azure-pipelines/trigger-reference-docs-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ name: Azure CLI Trigger Reference Docs CI

trigger:
branches:
exclude:
- '*'
tags:
include:
- release
- release-lts-*
- test-release-*
- azure-cli-*
Comment thread
wangzelin007 marked this conversation as resolved.

pr: none

Expand All @@ -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:
Expand All @@ -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-<ver>' = 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."
}
Comment thread
wangzelin007 marked this conversation as resolved.

$definitionId = $triggerBranch -like 'release-lts-*' ? $env:AdoLtsPipelineId : $env:AdoLatestPipelineId
$variables = @("triggerBranch=$triggerBranch", "triggerFromRepo=$thisRepoLink", "triggerByPipeline=$thisRunLink")

Expand All @@ -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)
Loading