I am trying to set environment in the Azure DevOps build pipeline conditionally based on the trigger branch.
I tried something like this:
jobs:
- deployment: Deploy
${{ if eq(variables['Build.SourceBranch'], 'DEV') }}:
environment: DEV
${{ if eq(variables['Build.SourceBranch'], 'TEST') }}:
environment: TEST
however no luck.
Any ideas how to set it correctly?
Build.SourceBranch will contain refs/heads/ in front of the branch name:
Git repo branch:
refs/heads/masterGit repo pull request:
refs/pull/1/merge
If you want just the final name part (after the last /), use Build.SourceBranchName.
See:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With