AzureDevOps Release pipeline with multiple artifacts

こ雲淡風輕ζ 提交于 2021-02-08 13:33:20

问题


Is it possible to have a single release pipeline with multiple artifacts that will trigger separate stages conditionally.

Example:

(Build Artifact 1) Build tags of Web

(Build Artifact 2) Build tags of Identity

When i setup my release pipeline I create one pipeline and add the

(Build Artifact 1) -> Web Stage

(Build Artifact 2) -> Identity Stage

both of those artifacts are set trigger a release automatically and set to After Release

The problem I have is that when I queue the build for (Build Artifact 2) both stages will deploy. And i only want Identity Stage to deploy and visa versa.

The reason i want everything in one pipeline is because then all my artifacts is contained in one pipeline, I know i can do this if i create separate pipelines.


回答1:


Thinking more about your situation, it might be cleaner (read: no failing stages) to have a third artifact producing CI that is triggered on the build completion of the other 2 CI builds. That mediation build would get tagged according to why it was triggered (ie. Web or Identity). The artifact of this build would be a re-packaging of the upstream artifact (use the download artifact task), allowing your release pipeline to consume one artifact that might have 2 different tag values. This gives your artifact filters in pre-release conditions more teeth.

Web_CI                            
    \                             #Web - - Web Development - - Web Production
     - -\                        /
         > = WebIdSwitch_CI - - <
     - -/                        \
    /                             #Id - - Id Development - - Id Production
Id_CI


Original Answer

I could be wrong about this, but I think you're going to need to have the stages run based on the value in RELEASE_TRIGGERINGARTIFACT_ALIAS.

There might be a couple ways to do this, such as

  1. having a buffer stage for per artifact after release and letting them fail if the value isn't right (moving your working stage to execute after its buffer)
  2. do the check in the job with a new first task and fail that
  3. write a conditional execution option on every task to make sure that none of them execute if the triggering artifact isn't right

The variable can be accessed on the pipeline using $(Release.TriggeringArtifact.Alias) or in powershell with $env:RELEASE_TRIGGERINGARTIFACT_ALIAS.

I'm not sure if you're using Artifact Filters on your stages already as part of your pre-deployment conditions, but that may be another way that isn't as much of a hack. I'll have to put a test pipeline together and try it out.



来源:https://stackoverflow.com/questions/55734824/azuredevops-release-pipeline-with-multiple-artifacts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!