We created a new build agent pool for Visual Studio 2022 in Azure DevOps. To check if everything works, we temporarily switched jobs to the new agent pool. That worked for most jobs, but not for all. A few where stubborn and keep running on the old agent pool. How can that be?
As it turns out there are three and not just two places where we can choose the agent pool.
When we run the pipeline
If we click on the “Run Pipeline” button, Azure DevOps asks us where we want to run the job:
Here we can overwrite predefined settings and change the agent pool for a single run of the pipeline. That usually works, but not in our case.
In the pipeline definition
When we edit our pipeline, we can choose the agent pool in the first step:
Here we can set the default agent pool that our job runs in if we do not say anything different when we run the pipeline. It is also used for all the runs in which a trigger (CI or time) starts the pipeline.
In the agent job settings
The third and often overlooked place for setting the agent pool is in the agent job step that we can reach by editing the pipeline:
By default, this value is set to <inherit from pipeline>. As long as you do not change it, the two other places define in which agent pool your pipeline runs.
However, if you set a specific agent pool then the two other places cannot overwrite this setting and your job runs on the old agent pool.
Conclusion
The most important setting that defines where a job runs is in the agent job. Make sure that you set it to inherit from pipeline so that you can easily switch between agent pools.