How to Run on Self-Hosted Agents in Azure Pipelines
Name a self-hosted pool instead of a Microsoft-hosted vmImage to run jobs on agents you control.
Register agents into a pool, then set pool.name to that pool. Add demands to require capabilities so a job only runs on an agent that advertises them.
Steps
- Create an agent pool and register one or more self-hosted agents.
- Set
pool.nameto the pool instead ofvmImage. - Add
demandsto require specific capabilities.
Pipeline
azure-pipelines.yml
pool:
name: linux-builders
demands:
- docker
- Agent.OS -equals Linux
steps:
- script: docker build -t app .
displayName: Build on a self-hosted agentGotchas
- A job stays queued indefinitely if no online agent satisfies its demands.
- Capabilities come from the agent environment; set custom ones in the pool UI.
- Self-hosted agents preserve disk state between runs, so clean workspaces yourself if needed.
Related guides
How to Run a Bash or PowerShell Script Step in Azure PipelinesRun shell scripts in Azure Pipelines with the Bash@3 and PowerShell@2 tasks, choosing inline scripts or a fil…
How to Run Jobs in Parallel With a Matrix in Azure PipelinesFan one Azure Pipelines job out into parallel jobs with a matrix strategy, defining named legs that each set…