Using matrix jobs
On This Page
Matrix jobs provide a way to run a job multiple times with arguments. Arguments are supplied using parameters. There are many uses for this feature, including testing on multiple operating systems and against different language or library versions.
Use matrix jobs to run multiple OS tests
In the following example, the
test job is run across a Linux Docker container, Linux VM, and macOS environments, using two different versions of Node.js. On each run of the
test job, different parameters are passed to set both the OS and the Node.js version:
|Using Docker? Authenticating Docker pulls from image registries is recommended when using the Docker execution environment. Authenticated pulls allow access to private Docker images, and may also grant higher rate limits, depending on your registry provider. For further information see Using Docker authenticated pulls.|
version: 2.1 orbs: node: email@example.com executors: docker: # Docker using the Base Convenience Image docker: - image: cimg/base:stable linux: # a Linux VM running Ubuntu 20.04 machine: image: ubuntu-2004:202107-02 macos: # macos executor running Xcode macos: xcode: 14.2.0 jobs: test: parameters: os: type: executor node-version: type: string executor: << parameters.os >> steps: - checkout - node/install: node-version: << parameters.node-version >> install-yarn: true workflows: all-tests: jobs: - test: matrix: parameters: os: [docker, linux, macos] node-version: ["14.17.6", "16.9.0"]
List jobs that will run
The expanded version of this matrix runs the following list of jobs under the
- test-14.17.6-docker - test-16.9.0-docker - test-14.17.6-linux - test-16.9.0-linux - test-14.17.6-macos - test-16.9.0-macos
For full details of the matrix jobs specification, see the Configuration Reference.
Help make this document better
This guide, as well as the rest of our docs, are open source and available on GitHub. We welcome your contributions.
- Suggest an edit to this page (please read the contributing guide first).
- To report a problem in the documentation, or to submit feedback and comments, please open an issue on GitHub.
- CircleCI is always seeking ways to improve your experience with our platform. If you would like to share feedback, please join our research community.
Our support engineers are available to help with service issues, billing, or account related questions, and can help troubleshoot build configurations. Contact our support engineers by opening a ticket.
You can also visit our support site to find support articles, community forums, and training resources.
CircleCI Documentation by CircleCI is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.