0
votes

Im struggling to find any documentation to select a specific build agent that's in a given pool via our yaml azure pipeline file. Right now were selecting the pull to launch the job on but I'm having massive deployment issues with our servers and need to individually select the one I want to run the job on have anyone ever had to do something like this before?

trigger:
  batch: true
  branches:
    include:
    - master
  paths:
    exclude:
    - README.md

pool: 'ZupaDeploymentPool'
2

2 Answers

3
votes

You can use Demands to make your pipeline run on a specific build agent. See below steps:

1, Specify a user defined capability (you can use the System capabilities too)

Go to Project Settings-->Agent pools of Pipelines-->Select your Agent Pool-->Go to Agents tab--Select your Agent-->Click Capabilities-->Click **+** to add a user defined capability. See this the detailed steps and screenshots here.

enter image description here

Then you can define the demands in your yaml pipeline like below: The pipeline will only run on the build agent which i defined the capability Tag = agent1 in above step.

pool: 
  name: agengPoolName
  demands: 
  - Tag -equals agent1

You can also use the system capabilities without defining your own capabilities in demands. See below i use the system capabilities Agent.Name

 pool:
   name: Default
   demands: 
   - Agent.Name -equals myagentName
0
votes

I have done it with the UI but not when coding it in YAML but the concepts will be applicable:

You put the Agent.Name you are trying to select into the Build -> Options -> Demands section of the pipeline definition. In the UI it reads like

Agent.Name        equals       Foo

Based on that demand, that build will only go to the specified agent within the pool...

For the YAML-defined Build, the Demands are defined as shown here.