3

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 😊

2 Answers 2

5

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for this answer, helped me save lots of time.
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

1 Comment

'Evaluates True if left parameter is equal to any right parameter' not the same as contains. (string exists in string)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.