'Azure Devops Conditional Release Pipeline
I am using an NX monorepo. I am currently setting up the CI/CD pipelines for this in Azure DevOps.
The build pipelines are fine I think but looking at the release pipeline I will need some sort of condition check as the build artefacts may or may not be there, given only what has been affected will be built at that time.
For example I have 4 apps in the monorepo and I apply a fix to App2 then only the build artefact for App2 will be available for deployment. For App1,App3 and App4 there will be no artefact
So I was thinking I would have 4 release tasks/templates within the release pipeline- 1 for App1, 1 for App2 etc
In each task/template I would have a condition that checks to see the artefact exists and if so continue release deployment otherwise exit
eg. if $(System.DefaultWorkingDirectory)/dist/apps/App1 folder exists then do deployment
Is it possible to do something like this in Yaml? (I still mainly use the UI task editor!)
Solution 1:[1]
You can use conditions on the deployment step. As example:
Add the first step: check folders and update some variable. To update your variable you can use logging commands:
Write-Host "##vso[task.setvariable variable=your_variable]YES"Use the variable in the condition of the deployment step:
and(succeeded(), eq(variables['your_variable'], 'YES'))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Shamrai Aleksander |
