How to fix duplicate key for variables

Viewed 201

When I try to add below code to pipeline I got message "duplicate key" for buildVersion:

trigger: none

pool:
  vmImage: 'windows-latest'

variables:
  ${{ if endsWith( variables['Build.SourceBranchName'], 'master' ) }}: 
    buildVersion: 'master'
  ${{ else }}: 
    buildVersion: 'none-master'

Do you have any idea how to fix it?

1 Answers

You code is fine, I've tested it and it works. The problem is the Pipeline editor. It doesn't seem to be able to parse the Conditional so it will give you squiggly lines and an error message but you can ignore it.

Related