在 Azure DevOps 多阶段管道中部署预先存在的项目

Deploy a preexisting artifact in a Azure DevOps Multi-Stage pipeline

在 Azure DevOps 经典管道中,您可以有一个用于创建工件的构建管道和一个用于部署它的发布管道。这意味着可以部署任何存储的预先存在的工件,只需启动发布管道并选择工件的版本(典型用法:将当前部署的工件回滚到以前的版本)

如何在多阶段管道中实现这一点?有什么方法可以只启动部署阶段选择要部署的工件吗?

此致

How this can be achieved in Multi-Stage pipeline? Any way of launching only the deployment stage selecting the artifact to be deployed?

的确,根据实际需求选择已有的工件非常方便,但是你想要的目前在Multi-Stage pipeline中还不支持

此请求已报告给 MS 产品团队:

Select artifacts in YAML release pipeline

此功能已在上次冲刺中添加:

Pipeline resource version picker in the create run dialogue

但是,据我测试,这个功能似乎并没有在所有地区部署:

如果它没有部署在您所在的地区,您可以尝试使用 Download Pipeline Artifacts task 任务和 runId 输入:

- task: DownloadPipelineArtifact@2
  inputs:
    source: 'specific'
    artifact: 'drop'
    path: $(Build.SourcesDirectory)/bin
    project: 'AndroidBuild'
    pipeline: 12
    runVersion: 'specific'
    runId: $(buildid)

然后在我们对构建进行排队时使用传递队列变量buildid

希望这对您有所帮助。

这可以通过两条管道来完成。一个管道用于您的构建,您的管道在其中生成工件并为您的发布阶段创建另一个管道。在发布管道中,您可以将资源设置为指向另一个构建或管道。您可以在部署阶段使用之前生成的工件(包括旧构建版本)。

参见: YAML Resources

您的发布 YAML 管道可以指定它需要的资源。您可以指定现有构建或其他管道。

resources:
  pipelines:
  - pipeline: SmartHotel-resource # identifier for the resource (used in pipeline resource variables)
    source: SmartHotel-CI # name of the pipeline that produces an artifact

但是,将它们分开只会导致移动开销和维护。