> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/open-source/use-harness-open-source/pipelines-1/matrix.md).

# Matrix

A matrix strategy can be used to test multiple versions of tools in a single pipeline step definition.

## Single-dimension <a href="#single-dimension" id="single-dimension"></a>

This pipeline runs two test steps with different versions of the `node` Docker image .

```yaml
kind: pipeline
spec:
  stages:
  - type: ci
    spec:
      steps:
      - name: test
        type: script
        strategy:
          type: matrix
          spec:
            axis:
              node_version: [ "12", "14" ]
        spec:
          image: node:${{ matrix.node_version }}
          run: |-
            npm install
            npm test
```

## Multi-dimension <a href="#multi-dimension" id="multi-dimension"></a>

This pipeline runs four test steps with different versions of the `python` Docker image and `pytorch` package.

```yaml
kind: pipeline
spec:
  stages:
  - type: ci
    spec:
      steps:
      - name: test
        type: script
        strategy:
          type: matrix
          spec:
            axis:
              python_version: [ "3.10", "3.11" ]
              pytorch_version: [ "1.13.1", "2.0.0" ]
        spec:
          image: python:${{ matrix.python_version }}
          run: |-
            pip3 install torch==${{ matrix.pytorch_version }}+cpu --index-url https://download.pytorch.org/whl/cpu
            pytest
```
