Ad

Azure DevOps Conditional For Multiple Values

I have been following this Microsoft doc and created a release pipeline in YAML, all works fine.

I have a conditional step that works fine as well:

- ${{ if contains(parameters.environment, 'PROD') }}:

Now requirement changed a bit, and the same conditional step requires checking against multiple values.

Like if this contains PROD or UAT the true.

I have been reading differnt places and tried following without luck:

- ${{ or(if contains(parameters.environment, 'PROD'), if contains(parameters.environment, 'UAT')) }}:

- ${{ if contains(parameters.environment, 'PROD', 'UAT') }}:

Any idea if this is possible and how to solve it? much appreciated 😊

Ad

Answer

Take for example the below:

${{ if or( eq(parameters.environment, 'PROD'), eq(parameters.environment, 'UAT') ) }}:

expressions syntax:

https://docs.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops#functions

Ad
source: stackoverflow.com
Ad