I'm trying to create a yaml pipeline with three stages that can be executed in different orders depending on the Pull Request source branch. For example:
If var = default then
- Stage A
- Stage B
- Stage C
If var != default then
- Stage A
- Stage C
- Stage B
Here's what I have so far: variables:
- name: abcDependsOn
${{ if not(contains(variables['System.PullRequest.SourceBranch'], 'hotfix' )) }}:
value: 'Publish'
${{ if contains(variables['System.PullRequest.SourceBranch'], 'hotfix' ) }}:
value: 'DeployXYZ'
- name: xyzDependsOn
${{ if not(contains(variables['System.PullRequest.SourceBranch'], 'hotfix' )) }}:
value: 'DeployABC'
${{ if contains(variables['System.PullRequest.SourceBranch'], 'hotfix' ) }}:
value: 'Publish'
stages:
- stage: Publish
jobs:
- job: publish
- stage: DeployABC
dependsOn: ${{ variables.abcDependsOn }}
jobs:
- job: deployabc
- stage: DeployXYZ
dependsOn: ${{ variables.xyzDependsOn }}
jobs:
- job: deployxyz
This isn't work because the dependsOn template expression variables are being evaluated before the runtime expression variables (I think). Is this even possible?