Skip to content
Latchkey

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 test

Notes

  • 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

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