Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AzureDevOps Release pipeline with multiple artifacts

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.

like image 434
R4nc1d Avatar asked Apr 17 '19 19:04

R4nc1d


People also ask

Can we link multiple Artifacts with one release definition?

A single release pipeline can be linked to multiple artifact sources, of which one is the primary source. In this case, when you create a release, you specify individual versions for each of these sources.

What is multistage pipeline in Azure DevOps?

A pipeline is comprised of Stages, Jobs, and Steps. A stage contains multiple jobs and jobs contain multiple steps. The YAML syntax following the outline above would be: stages: - stage: Build.

What is the difference between Build and release pipelines in Azure DevOps?

Conclusion. The Azure DevOps Server provides two different types of pipelines to perform build, deployment, testing and further actions. A Build Pipeline is used to generate Artifacts out of Source Code. A Release Pipeline consumes the Artifacts and conducts follow-up actions within a multi-staging system.

What is Artifacts in Azure DevOps pipeline?

Azure Artifacts enable developers to consume and publish different types of packages to Artifacts feeds and public registries such as NuGet.org and npmjs.com.


1 Answers

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.

like image 112
Josh Gust Avatar answered Oct 01 '22 06:10

Josh Gust