Skip to content
Latchkey

How to Run Jobs in Parallel With a Matrix in Azure Pipelines

A matrix strategy clones one job into several parallel legs, each with its own variable values.

Add strategy.matrix to a job with one entry per leg. Each entry is a name plus a map of variables, and Azure DevOps runs the legs in parallel up to maxParallel.

Steps

  • Add strategy.matrix to the job.
  • Give each leg a name and a map of variables.
  • Reference a matrix variable as $(name) inside the steps.
  • Cap concurrency with maxParallel if needed.

Pipeline

azure-pipelines.yml
jobs:
  - job: test
    strategy:
      maxParallel: 3
      matrix:
        linux:
          imageName: ubuntu-latest
        windows:
          imageName: windows-latest
        mac:
          imageName: macos-latest
    pool:
      vmImage: $(imageName)
    steps:
      - script: npm ci && npm test

Gotchas

  • Each leg counts as a parallel job and consumes a parallelism slot.
  • Matrix variables are available as $(name) in steps and in the pool selection.
  • For a self-healing managed pool, parallel matrix legs retry transient agent dropouts automatically.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →