Search code examples
azure-devopscontinuous-integrationyaml

Azure devops Yaml :how to set for loop over agent pool name


I have a use case to run the same stage on different Azure pool name, looking to have a logic to iterate over the pool name

Is there something like this which can work ?

stages:
- ${{ each name in parameters.poolNames }}:
 - stage: Stage1
   jobs:
   - job: Job1
     pool:
       name: ${{parameters.poolNames}}
     steps:
     - script: echo Hello, world!
       displayName: "Run echo hello world ${{parameters.regionName}} ${{parameters.poolName}}"

Solution

  • I think what you are looking for is the matrix strategy. Have a look at this example, you should be able to adapt it your use case.