Azure DevOps触发流水线无法获取对应触发构建工件的问题求助
Azure DevOps流水线DownloadPipelineArtifact任务无法匹配触发构建对应工件问题
我在运行Azure DevOps(ADO)流水线时遇到问题:使用DownloadPipelineArtifact任务无法下载触发当前流水线的构建所生成的工件。
需求是:流水线A生成工件,流水线B由A的成功构建触发,希望B的每一次运行(B1、B2、B3)分别对应获取A的对应构建(A1、A2、A3)生成的工件(a1、a2、a3)。ADO的DownloadPipelineArtifact@v2任务有一个specificBuildWithTriggering选项,理论上可实现此功能,但实际所有B的运行都下载最新的工件(如a3),而非对应触发构建的工件。
当前执行流程:
A1 --> a1 --> B1触发 --> 下载并使用a3(应为a1) A2 --> a2 --> B2触发 --> 下载并使用a3(应为a2) A3 --> a3 --> B3触发 --> 下载并使用a3(正确)
流水线A(生成工件)
此流水线ID为XXXX,会保存runName参数值到工件中。
# pipeline A trigger: none parameters: - name: runName displayName: Tag name (run name) type: string default: test-tag stages: - stage: displayName: Info jobs: - job: info displayName: Display info pool: vmImage: ubuntu-latest steps: - bash: | echo "This is triggering another pipeline" echo "Putting ${{ parameters.runName }} into $(System.DefaultWorkingDirectory)/runName" echo ${{ parameters.runName }} > $(System.DefaultWorkingDirectory)/runName displayName: 'Create runName file for publish' - publish: $(System.DefaultWorkingDirectory)/runName artifact: runName
流水线B(触发后获取工件)
# pipeline B trigger: none # do not start automatically unless specific trigger is defined below resources: repositories: - repository: another-helper-repo type: git name: ourproject/repo1 ref: refs/tags/sometag - repository: tenant type: git ref: refs/heads/main name: ourproject/repo2 pipelines: - pipeline: a-trigger source: ourproject/A # the triggering pipeline name project: ourproject trigger: true stages: - stage: jobs: - job: A steps: - task: DownloadPipelineArtifact@2 inputs: buildType: 'specific' project: 'ourproject' definition: 'XXXX' # triggering pipeline ID specificBuildWithTriggering: true # use the build ID that has triggered you artifactName: '' # all artifacts targetPath: $(System.ArtifactsDirectory) - bash: | echo "Working..." echo "System.ArtifactsDirectory: $(System.ArtifactsDirectory) - listing :" ls -al $(System.ArtifactsDirectory) echo "runName value:" cat $(System.ArtifactsDirectory)/runName/runName name: Information
当流水线A多次运行(分别传入test1、test2、test3作为runName参数),触发的流水线B均获取到test3的值,而非对应触发构建的参数值。请问我哪里配置错误?
内容的提问来源于stack exchange,提问作者Maciej Rostański
相关产品推荐
相关产品推荐

