How to Run a Matrix Across OS in Azure Pipelines
A strategy matrix multiplies a job across vmImage values so each OS runs the same steps.
Define a matrix where each leg sets a different imageName, then reference $(imageName) as the pool vmImage so one job covers all three OSes.
Matrix over vmImage
Each matrix leg picks a vmImage; the pool reads it via a variable.
azure-pipelines.yml
jobs:
- job: Test
strategy:
matrix:
linux:
imageName: ubuntu-latest
windows:
imageName: windows-latest
mac:
imageName: macOS-latest
pool:
vmImage: $(imageName)
steps:
- script: npm ci && npm testNotes
- maxParallel under strategy caps how many legs run at once.
- Each leg gets its own agent and workspace, so there is no cross-OS contamination.
- macOS agents have lower parallel limits on hosted pools; plan capacity accordingly.
Related guides
How to Use Variable Templates in Azure PipelinesShare variables across Azure Pipelines with a variable template file, including it under variables so many pi…
How to Run a Container Build in Azure PipelinesBuild and push a container image in Azure Pipelines with the Docker@2 task and an Azure Container Registry se…