Azure Devops 将构建 ID 作为参数传递给 YAML 部署管道

时间:2021-06-24 23:09:16

标签: azure-devops azure-pipelines devops azure-pipelines-yaml azure-devops-pipelines

我想在 YAML 部署管道中创建一个参数,让用户在手动运行时提及他们想要传递用于部署的构建 ID。

如何使用在部署管道内部署期间作为参数传递的特定构建 ID?

部署管道资源定义为:

resources:
  pipelines:
  - pipeline: build 
    source: build_pipeline_name 
    trigger:
      branches:
      - master

由于对我们在管道中使用的环境的访问限制,无法从资源中进行选择。

1 个答案:

答案 0 :(得分:0)

如果您只想下载特定的工件,您将无法仅使用资源来执行此操作,因为您无法参数化资源。但是,如果这是您的目标,您可以参数化此任务:

parameters:
- name: runId
  type: number

# Download an artifact named 'WebApp' from a specific build run to 'bin' in $(Build.SourcesDirectory)
steps:
- task: DownloadPipelineArtifact@2
  inputs:
    source: 'specific'
    artifact: 'WebApp'
    path: $(Build.SourcesDirectory)/bin
    project: 'FabrikamFiber'
    pipeline: 12
    runVersion: 'specific'
    runId: ${{ parameters.runId }}


不过,我不确定我是否理解你。