I am trying to parameterize the agent.name in azure pipeline. The objective is to give the user the option to deploy the code in the desired machine. So I have created a pool with a few machines in it and parameterize the agent.name
Code
parameters
- name: machinename
displayName: machinename
type: string
values:
- 10.72.1.123
- 10.72.1.124
pool:
name: PoolA
demands:
- agent.name -equals ${{ parameters.machinename}}
Error : When trying to run the above code , I get the below error.
A template expression is not allowed in this context
Please help in resolving this issue.
You may try to use this workaround:
trigger: none
pool:
name: Default
demands:
- agent.name -equals $(machinename)
jobs:
- job:
displayName: 'Job 1'
steps:
- task: Bash@3
inputs:
targetType: 'inline'
script: |
echo "$(machinename)"
then please define pipeline variable (on editing pipeline):
Make this variable available of overwriting:
and then n running pipeline:
You will not get dropdown list, but this is the only way to overcome this issue.