I'm trying to run a different build mode depending on the target branch in an Azure Devops pipeline so I created a variable and an if/ese.
According to this MS Documentation, it appears that I'm doing things correctly. My IDE that does syntax/error checking doesn't complain about the YAML.
However, when I try to run the build pipeline, I get "Duplicate Keys" as an error for the buildScript variable. Does anyone know a way around this? Or am I just doing something silly in my YAML?
I was under the impression duplicate keys were allowed in YAML.
variables:
slotTarget: 'development'
${{ if eq(variables['Build.SourceBranchName'], 'main') }} :
buildScript: build
${{ else }} :
buildScript: devBuild
jobs:
- job: buildApp
displayName: 'Build the Vue App'
#Set ENV.VARS for Webpack to read and inject during build
- bash: |
echo Running build for $BUILDNUM
BUILDNUMBER=$BUILDNUM npm run $(buildScript)
displayName: 'Create Build - $(build.buildNumber) for GIT $(build.SourceVersion) Trigger: $(build.Reason)'
env:
BUILDNUM: $(build.buildNumber)
Edit: I'm starting to suspect that there are different versions of the Azure DevOps pipeline parser. Maybe based on subscription age? Seems like the same code works for some people and not others. Can anyone verify this?

