How to Run Matrix Jobs With parallel:matrix in GitLab CI/CD
parallel:matrix clones a job once per combination of the listed variables, each running in parallel.
Add parallel:matrix with one or more variables, each holding a list of values. GitLab creates one job per combination and injects the values as variables.
Steps
- Add
parallel:matrixwith a list of variable maps. - Reference the variables in
scriptorimage. - Each combination runs as its own parallel job instance.
Pipeline
.gitlab-ci.yml
test:
image: node:${NODE_VERSION}
parallel:
matrix:
- NODE_VERSION: ["18", "20", "22"]
SUITE: [unit, integration]
script:
- npm ci
- npm run test:${SUITE}Gotchas
- Total jobs equal the product of every list, so large matrices consume many runner slots.
- A downstream
needs:on a matrix job must useneeds:parallel:matrixto pick a specific combination.
Related guides
How to Build a DAG Pipeline With needs in GitLab CI/CDRun GitLab CI/CD jobs out of stage order with needs, letting a job start as soon as its specific dependencies…
How to Retry Flaky Jobs in GitLab CI/CDAutomatically re-run a flaky GitLab CI/CD job with the retry keyword, capping attempts and scoping retries to…