问题
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
- 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)
- do the check in the job with a new first task and fail that
- 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