How to Run a Matrix Build in Azure Pipelines
Azure Pipelines fans a job across combinations with strategy: matrix, each exposing its values as variables.
Define named matrix legs under strategy: matrix. Each leg becomes a parallel job copy; the leg's key/value pairs are available as variables.
Matrix across Node versions
Each named leg sets variables consumed by the steps; maxParallel caps concurrency.
azure-pipelines.yml
jobs:
- job: test
strategy:
maxParallel: 3
matrix:
node18:
NODE_VERSION: '18.x'
node20:
NODE_VERSION: '20.x'
node22:
NODE_VERSION: '22.x'
pool: { vmImage: 'ubuntu-latest' }
steps:
- task: NodeTool@0
inputs: { versionSpec: $(NODE_VERSION) }
- script: npm ci && npm testGotchas
- Each matrix leg is named; that name shows in the run and must be unique within the job.
maxParallellimits concurrent legs - useful to stay within your parallel-job license.- For test slicing (not version fan-out), set
parallel: Non the job and useSystem.JobPositionInPhase/System.TotalJobsInPhase.
Related guides
How to Use Matrix Builds in GitHub ActionsUse GitHub Actions matrix builds to test across versions and OSes in parallel - strategy.matrix, include/excl…
How to Cache Dependencies in Azure PipelinesCache dependencies in Azure Pipelines with the Cache@2 task - lockfile-based keys, restoreKeys fallbacks, and…