Search code examples
azureazure-devopsyamlazure-pipelinesdevops

Create Azure Devops agent job multiplier variables using YML


Background

As I understand it, when creating a release pipeline in classic mode in Azure DevOps, you are provided the option to run your job with the Parallelism Execution plan. Once you select that plan, you can provide a Multipliers variable(s) that will run your job once for every multiplier variable you provide, switching out the variable value for every value in your comma separated string.

So for example, if I created the following release pipeline job:

enter image description here

And provided the following pipeline variable: TenantName: Tenant001, Tenant002, Tenant003 

My pipeline would be run 3 times - once for each variable value.

Question

Is it possible to do the same thing with yml for a build pipeline?

The closes thing I found is the parallel job strategy but that provides no option for a Multiplier variable.


Solution

  • Upon further investigation, I think I found the answer.

    We can use the matrix strategy combined with some simple logic to expand a pipeline variable into multiple values via bash.

    enter image description here