Forum Discussion
walark
Jul 15, 2024Copper Contributor
Creating variables based on conditions with other variables
Hello all, I am quite new to azure devops and I am struggling with understanding why my approaches to do something in the pipelines doesn't work. Starting from a template, I have such a piece o...
sdtslmn
Jul 25, 2024MCT
I think you can go with the following
variables:
- name: isRelease
value: eq(variables['Build.SourceBranch'], 'refs/heads/master')
- name: isSnapshot
value: eq(variables['Build.SourceBranch'], 'refs/heads/develop')
- name: artifactoryUrl
value: ${{ if and(eq(variables['isRelease'], true), ne(variables['Build.Reason'], 'Schedule')) }}:
someUrl1
${{ if and(eq(variables['isSnapshot'], true), ne(variables['Build.Reason'], 'Schedule')) }}:
someUrl2
${{ if or(and(eq(variables['isRelease'], false), eq(variables['isSnapshot'], false)), eq(variables['Build.Reason'], 'Schedule')) }}:
''