I have a pipeline in which I need to push the agent poolname of the current running build as a variable but couldnt find any predefined variables from azure devops.
Demo-yml-pipeline below:
name: $(BuildID)
trigger: none
pool: Self Hosted Docker (Linux)
steps:
- powershell: |
Write-Host "want poolname on which the pipeline is running"
Thanks.
Fount Agent.name here but it is returning agentName instead of poolname.
To my knowledge, there is no built in way way to fetch the pool name.
I can think of two options you could use to obtain it.
If you have access to the agent, you can create an enviroment variable and reference that in your script.
In Linux, you can use export poolName=poolValue
, and then reference it in powershell. Note that environment variables in linux are case sensitive.
name: $(BuildID)
trigger: none
pool: Self Hosted Docker (Linux)
steps:
- powershell: |
Write-Host $env:poolName
You can define your pool name in a variable, and use that variable to reference the pool.
name: $(BuildID)
trigger: none
variables:
- name: poolName
value: 'Self Hosted Docker (Linux)'
pool: $(poolName)
steps:
- powershell: |
Write-Host $(poolName)