Reputation: 131
I have this yaml, how can I set the pool to the value selected in the drop down list? Obviously what I have now doesn't work. It complains that the template expression is not allowed in this context.
parameters:
- name: InstallNodeJS
displayName: 'Install Node.js'
type: boolean
default: false
- name: AgentPoolSelector
displayName: Select Agent Pool
type: string
default: Default
values:
- Default
- Cloud
- Dev Machines
variables:
custom.branch: 'my-branch'
pool:
name: $ {{ parameters.AgentPoolSelector }}
steps:
- ${{ if eq(parameters.InstallNodeJS, true) }}:
- template: templates/nodejs-install.yml
Upvotes: 2
Views: 1561
Reputation: 28176
Per my test, to set the Pool name based on Runtime parameters we should insert the pool into one job/stage-level. You can try this format to resolve the issue:
parameters:
- name: InstallNodeJS
displayName: 'Install Node.js'
type: boolean
default: false
- name: AgentPoolSelector
displayName: Select Agent Pool
type: string
default: Default
values:
- Default
- Cloud
- Dev Machines
variables:
custom.branch: 'my-branch'
jobs:
- job:
displayName: FirstJob
pool:
name: ${{ parameters.AgentPoolSelector }}
steps:
- ${{ if eq(parameters.InstallNodeJS, true) }}:
- template: templates/nodejs-install.yml
Upvotes: 3