I have an Azure multi-stage CI/CD pipeline. It has stages for Test and UAT deployment.
I want the UAT release to run if Test succeeds or is skipped, but not if it fails.
I can't. Whatever I try, if Test is skipped, UAT is also skipped. Unless I use always()
, but then UAT will run even if Test fails.
...
- stage: Test
condition: and(succeeded(), ne(variables['build.sourceBranchName'], 'DoUAT')) # Skip for UAT deployment tests
...
- stage: UAT
condition: and(succeeded(), in(variables['build.sourceBranchName'], 'master', 'DoUAT')) # Only deploy off master branch and branch to test UAT deploys.
...
How do I skip one stage but not the next one?
You can use not(failed('Test'))
condition, please try below condition.
- stage: UAT
condition: and(not(failed('Test')), in(variables['build.sourceBranchName'], 'master', DoUAT')) # Only deploy off master branch and branch to test UAT deploys.
...
I tested and it worked, check below screenshot.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With