How to demand multiple agent machines in Azure devops pipeline pool?

Viewed 6704

I'm looking if I can specify a list of agents in Agent pool demands? In UI azure pipeline has only two options equals and exists. So, I tried adding two demands but pipeline takes only first demand

Pipeline UI

The same in yaml is as follows,

pool:
  name: AWS Pool
  demands:
  - Agent.Name -equals simLin02
  - Agent.Name -equals ubuAgent01

I would like to know if there is any logical way of specifying the list of agent machines in yaml like following or any other alternatives where I can pass a list of agent names(specific agent names because not all agents in the pool have desired capability) for the pipeline to choose from.

pool:
  name: AWS Pool
  demands:
  - Agent.Name -in (simLin02, ubuAgent01)
1 Answers

Sorry but as I know Azure Devops doesn't support specifying the list of agent machines using the logical way above. Instead we can define user-defined capabilities if we want to pass a list of agents for the pipeline to choose from. See:

enter image description here

For example: If we define one custom capability called RunTest for agents simLin02 and ubuAgent01, then we can easily use something like this to choose the list which contains these two agents:

pool:
  name: Default
  demands: RunTest

Since only agents simLin02 and ubuAgent01 contain the RunTest capability, it will pick one of them to run the pipeline. It actually has same effect like - Agent.Name -in (simLin02, ubuAgent01) whose syntax is not supported.

Related