Azure Pipelines has Expressions and Conditions, but I can find no way to assign one of two values to a variable, based on a condition.
Is there any way to accomplish what this pseudo-code would?
${{ if endsWith( variables['Build.SourceBranchName'], '/master' ) }}:
buildVersion: variables['mavenVersion']
${{ else }}:
buildVersion: variables['Build.SourceBranchName']
I was closer than I thought. This is not pretty, but it worked. (with more yaml context)
variables:
${{ if eq( variables['Build.SourceBranchName'], 'master' ) }}:
buildVersion: ${{ variables['mavenVersion'] }}
${{ if ne( variables['Build.SourceBranchName'], 'master' ) }}:
buildVersion: ${{ variables['Build.SourceBranchName'] }}
buildKey: ${{ format('{0}_{1}', variables['supportReleaseNumber'], variables['buildVersion']) }}
buildNum: $[counter(variables['buildKey'], 1)] # same as $(Rev:r), but more widely usable
name: $(buildKey)_$(buildNum) # build run name