Azure管道|在两者之间创建线性依赖关系

6tdlim6h  于 2022-12-30  发布在  其他
关注(0)|答案(1)|浏览(117)

有两条流水线。第二条流水线应该在第一条流水线完成后触发。第二条流水线需要参数,该参数是从第一个作业接收到的ID。
我检查了webhook和触发器,但没有向作业传递参数的选项。是否有方法创建依赖项并向管道传递参数?

ve7v8dk2

ve7v8dk21#

要在两个管道之间创建依赖关系,您可以为第二个管道创建一个管道资源触发器,使其在第一个管道完成时自动运行。例如:

# First pipeline
steps:
- bash: echo "The first pipeline runs first"
# Second pipeline
# We are setting up a pipeline resource that references the first pipeline
# pipeline and setting up a pipeline completion trigger so that our second
# pipeline runs when a run of the first pipeline completes
resources:
  pipelines:
  - pipeline: firstPipeline # Name of the pipeline resource.
    source: first-pipeline # The name of the pipeline referenced by this pipeline resource.
    project: ProjectName # Required only if the source pipeline is in another project
    trigger: true # Run second pipeline when any run of first pipeline completes

steps:
- bash: echo "second pipeline runs after first pipeline completes"

有关详细信息,请参见Microsoft documentation
对于你的第二个问题,从一个管道传递一个变量到下一个管道,我找到的最好的解决方案是引用和更新管道变量组中的变量,参见文档here
例如:

# First pipeline 
# As a task in the first pipeline, update any pipeline 
# variables that other pipelines will need

- task: AzureCLI@2
  displayName: Update variable
  inputs:
    azureSubscription: azure-sub-arm
    scriptType: bash
    scriptLocation: inlineScript
    inlineScript: |
      az pipelines variable-group variable update --group-id <<id>> --name <<variable_name>> --value <<new_value>>

相关问题