1

We have several pipelines running on DevOps against a single build agent (a Windows build server) in the "Default" agent pool.

We want to test a new build server using different tools, so we'd create a new build agent on that machine and either create new pipelines for the new agent, or parameterize the pipeline (I assume this is possible).

Is it possible (and sensible) to have both agents in the same pool and directly control which build agent is used, or is the correct approach to create a 2nd pool, with one agent in each pool?

Mr. Boy
  • 60,845
  • 93
  • 320
  • 589

1 Answers1

2

It all depends. If you have very few pipelines you can use single agent pool and put inside also agent which you want to test. Why this is ok for very few. Becaus you can use demands to control which agent will be assigned to the pipelines. But since both agents are in the same pool if you do not do this explicit it will take any free agent available innthe pool.

To do this you need first set custom demands. Please go to Project Settings -> Agent Pools -> Select pool -> go to Agents tabb -> select agent -> go to capabilities and add User-defined capabilities

enter image description here

When you do this you can use this as demands in the pipeline:

pool:
  name: MyPool
  demands:
  - type -equals test

However it would be good to do the same for your stable agents and set type ready for instance. Then you will have to modify all your pipelines to control which pipeline should take which agent.

Another approach would be a separate agent pool and parameterize this via runtime parameters:

parameters:
- name: myString
  type: string
  default: 'default value!'
- name: mynum
  displayName: 'My Number Param'
  type: number
  default: 123
- name: mypool
  displayName: 'Pool'
  type: pool
  values:
  - ubuntu-latest
  - windows-latest
  - macos-latest

pool: ${{ parameters.mypool }}

steps:
- script: echo ${{ parameters.myString }} was entered at runtime!
- ${{ if not(eq(parameters.mynum, 123)) }}:
  - script: echo You overrode the default number to ${{ parameters.mynum }}

Like here

enter image description here

In this case you just need to change pipeline where you want to have test agents available to choose.

Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
  • Our pipelines currently have no `pool` config at all. If I add a 2nd pool, will existing pipelines still use `Default` - it seems logical they would but I don't want to mess things up testing! – Mr. Boy Jun 25 '21 at 12:54
  • So you are using some default pool. Which I'm not sure what it is. However if you define a pool inside the pipeline it will use the one defined. – Krzysztof Madej Jun 25 '21 at 13:01
  • Here you will find infmroation that you [cannot use two pools](https://stackoverflow.com/questions/64787969/can-i-use-2-agent-pools-in-my-azure-pipelines) – Krzysztof Madej Jun 25 '21 at 13:19
  • This confuses me, you have used a parameter to let me select which pool but if I can only have one pool, how does that make sense? – Mr. Boy Jun 25 '21 at 13:34
  • This is a proposal for solution with two pools. When you want to keep stable agents in one pool, and other for tests in another. – Krzysztof Madej Jun 25 '21 at 14:47