I've 2 variables in azure devops
Var1= A,B,C
Var2= 1,2
I need to run a task with the following conditions
Var1=A,B,C & Var2=1,2
Var1=A & Var2=1
From the official doc i can only able to see more simple custom conditions
like
and(succeeded(), in(variables['Var1'], 'A','B','C'))
Here how to include the Var2 using the and condition again more like multiple custom condition.
In a simple C# world we will wrote this like below
(Var1==A || Var1==B || Var1==C) && (Var2==1 || Var2==2)
Update
My final conditions looks like this
( ((Var1==A || Var1==B || Var1==C) && (Var2==2)) || ((Var1==A) &&(Var2==1)))
How could i achieve this in the custom conditions ?
Azure Devops multiple Custom conditions
It seems you want use the matrix variable, it is like every variable, you could use it in this way:
and(succeeded(), in(variables['Var1'], 'A','B','C'), in(variables['Var2'], '1','2'))
Separating variable conditions with commas, and it works fine on my side.
Hope this helps.
I have added a custom condition for the classic AzureDevops build pipeline requirement: the build should create an artifact if a branch is a master or release/* branch.
Custom condition is mention below:
and(succeeded(),or(eq(variables['Build.SourceBranch'], 'refs/heads/master'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/')))
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