4

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.

For if this contains PROD or UAT is true.

I have been reading different places and tried the 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

Maytham Fahmi
  • 31,138
  • 14
  • 118
  • 137

2 Answers2

6

Take for example the below:

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

expressions syntax:

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

GeralexGR
  • 2,973
  • 6
  • 24
  • 33
1

You could also use the in operator which makes it more concise IMO, like so:

${{ if in(variables['Build.Reason'], 'Manual', 'PullRequest') }}

reference: https://learn.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops#in

Maytham Fahmi
  • 31,138
  • 14
  • 118
  • 137
Bennimi
  • 416
  • 5
  • 14