Reputation: 375
I have a multi-stage YAML pipeline using a template. I would like to do different things depending on which git branch was pushed to. If it's master, I'd like to do one thing, and if it's dev, I'd like to do something else. I imagining something like
- task: ArchiveFiles@2
condition: eq(trigger, "master")
inputs:
rootFolderOrFile: 'C:\DevOps\$(Build.BuildNumber)\Content\D_C\a\1\s\api\obj\${{ parameters.configuration }}\Package\PackageTmp'
includeRootFolder: false
archiveType: 'zip'
archiveFile: 'C:\DevOps\artifacts\api-${{ parameters.configuration }}.zip'
replaceExistingArchive: true
verbose: true
- task: CopyFiles@2
condition: eq(trigger, "dev")
inputs:
SourceFolder: 'C:\DevOps\$(Build.BuildNumber)\Content\D_C\a\1\s\api\obj\${{ parameters.configuration }}\Package\PackageTmp'
Contents: '**\*.*'
OverWrite: true
TargetFolder: 'C:\QA\Web Sites\API${{ parameters.configuration }}'
Obviously this isn't going to work, because "trigger" is not defined. But if I wanted to act based on the git branch pushed to, how would I do this?
Upvotes: 0
Views: 171
Reputation: 375
I figured it out myself. Where I had
condition: eq(trigger, "master")
I just need to make it
condition eq(variables['Build.SourceBranch'], 'master')
Side note: In such comparisons, it turns out that double quotes don't work; I'm sure there's a reason, though I've never seen this mentioned in the documentation.
Upvotes: 1