My pipeline has a stage similar to this one
stages:
- stage: DeployToEnv
displayName: Deploy App
variables:
- group: Settings
- name: DOL.Environment
value: dev
jobs:
- template: ${{ parameters.postDeployJobTemplate }}
In my post-deploy template, I'd like to use a pool based on the environment, which is defined in the stage variables with variable DOL.Environment
I have tried:
1 - empty value
jobs:
- job: postDeployScriptStepsJob
displayName: Post Deploy Script Steps
pool:
${{ if eq(variables['DOL.Environment'], 'noprod') }}:
name: ${{parameters.poolNoProd}}
${{ if eq(variables['DOL.Environment'], 'prod') }}:
name: ${{parameters.poolProd}}
2 - syntax error
jobs:
- job: postDeployScriptStepsJob
displayName: Post Deploy Script Steps
pool:
- ${{ if eq('$(DOL.Environment)', 'noprod') }}:
name: ${{parameters.poolNoProd}}
- ${{ if eq('$(DOL.Environment)', 'prod') }}:
name: ${{parameters.poolProd}}
3 - variables not expected here
parameters:
- name: env
displayName: Environment
type: string
variables:
- ${{ if eq(parameters.env, 'noprod') }}:
- name: poolName
value: np
- ${{ if eq(parameters.env, 'prod') }}:
- name: poolName
value: pr
jobs:
- job: postDeployScriptStepsJob
displayName: Post Deploy Script Steps
pool:
name: $(poolName)
Unfortunately, since the stage is used by other teams too as part of another template, I cannot pass the pool name as a parameter however, I could pass the environment.
