19

I am trying to assign a specific agent on my agent pool but I don't know how to do it. Does anyone know it?

I tried with this but doesn't work:

- stage: Deploy
  pool: alm-aws-pool
    agent.name: deploy-05-agent1
NewLomter
  • 95
  • 1
  • 7
Dàniel Hernández
  • 307
  • 1
  • 3
  • 14

2 Answers2

42

The pool name needs to add to the name field, then you could add demands. You may try the following Yaml Code:

stages:
- stage: Deploy
  pool: 
   name: AgentPoolName(e.g. alm-aws-pool)
   demands:
    - agent.name -equals Agentname (e.g. deploy-05-agent1)
  jobs:
  - job: BuildJob
    steps:
    - script: echo Building!

Please check if it could work.

Hope this helps.

Kevin Lu-MSFT
  • 20,786
  • 3
  • 19
  • 28
  • 3
    Don't make the same mistake as me, enclosing the agent name in quotes. It will fail :( So don't write `- agent.name -equals 'Agentname'` – Michael Sep 15 '22 at 14:12
7

Use demands

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/demands?view=azure-devops&tabs=yaml

- stage: Deploy   
    pool: alm-aws-pool
    demands:
    - agent.name -equals deploy-05-agent1
Kontekst
  • 946
  • 8
  • 17