user3345547
user3345547

Reputation: 725

How to fix duplicate key for variables

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?

Upvotes: 2

Views: 970

Answers (1)

James Reed
James Reed

Reputation: 14052

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.

Upvotes: 4

Related Questions