@@ -25,56 +25,24 @@ jobs:
2525 env :
2626 AdoOrg : ${{secrets.ADO_DocsReference_Organization}}
2727 AdoProject : ${{secrets.ADO_DocsReference_Project}}
28- AdoPipelineId : ${{secrets.ADO_DocsReference_JumpPipeline_ID}}
29- CheckInterval : 60
28+ AdoLatestPipelineId : ${{secrets.ADO_DocsReference_Latest_Pipeline_ID}}
29+ AdoLtsPipelineId : ${{secrets.ADO_DocsReference_LTS_Pipeline_ID}}
30+ ReleaseBranch : ${{ github.event.release.target_commitish }}
3031 run : |
3132 $organization = $env:AdoOrg
3233 $project = $env:AdoProject
33- $definitionId = $env:AdoPipelineId
34- $checkInterval = $env:CheckInterval
34+ $thisRepoLink = "${{ github.server_url }}/${{ github.repository }}"
3535 $thisRunLink = "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
36- $triggerBranch = 'main'
37- $variables = @('commitAuthor=azcli', 'triggerFromRepo=https://github.com/Azure/azure-cli', "triggerBranch=$triggerBranch", "triggerByPipeline=$thisRunLink")
36+ $triggerBranch = $env:ReleaseBranch
37+ $definitionId = $triggerBranch -eq 'release' ? $env:AdoLatestPipelineId : $env:AdoLtsPipelineId
38+ $variables = @("triggerBranch=$triggerBranch", "triggerFromRepo=$thisRepoLink", "triggerByPipeline=$thisRunLink")
3839
3940 $output = az pipelines build queue --definition-id $definitionId --project $project --organization $organization --variables @variables | ConvertFrom-Json -AsHashtable
4041 if ($? -eq $false)
4142 {
4243 $pipelineDefinitionLink = $organization + [uri]::EscapeDataString($project) + "/_build?definitionId=$definitionId"
4344 Write-Error "Failed to queue the pipeline run for $pipelineDefinitionLink, please check above error message."
4445 }
45- $runIdInJumpPipeline = $output.id
46- Write-Host "runIdInJumpPipeline: $runIdInJumpPipeline"
47- do
48- {
49- Start-Sleep -Seconds $checkInterval
50- $status = az pipelines runs show --query status --id $runIdInJumpPipeline --project $project --organization $organization --output tsv
51- $currentTime = (Get-Date -AsUTC).ToString('yyyy-MM-dd HH:mm:ss')
52- Write-Host "[UTC $currentTime] apidrop shared jump pipeline run status: $status"
53- } while ($status -ne 'completed')
54- $jumpOutput = az pipelines runs show --id $runIdInJumpPipeline --project $project --organization $organization | ConvertFrom-Json -AsHashtable
55-
56- $targetPipelineResult = ($jumpOutput.tags -Match 'jump_return_result_(canceled|failed|partiallySucceeded|succeeded)')[0] -replace 'jump_return_result_', ''
57- $runId = ($jumpOutput.tags -Match 'jump_return_id_\d+')[0] -replace 'jump_return_id_', ''
58- $triggeredTargetPipeline = $runId ? $true : $false
59- if ($triggeredTargetPipeline)
60- {
61- # apidrop shared jump pipeline triggered target pipeline
62- $printMessage = 'Triggered reference pipeline run'
63- $printMessage += $targetPipelineResult ? " with its result $targetPipelineResult" : '' # waited for completion or not
64- }
65- else
66- {
67- # apidrop shared jump pipeline may fail to trigger target pipeline
68- $runId = $runIdInJumpPipeline
69- $printMessage = "Jump pipeline run with $($jumpOutput.result) state may fail to trigger reference pipeline"
70- }
46+ $runId = $output.id
7147 $runLink = $organization + [uri]::EscapeDataString($project) + "/_build/results?buildId=$runId"
72- $printMessage += ", for details please check: $runLink"
73- if ($triggeredTargetPipeline)
74- {
75- Write-Host $printMessage
76- }
77- else
78- {
79- Write-Error $printMessage
80- }
48+ Write-Host "Triggered reference pipeline run, for details please check: $runLink"
0 commit comments