Cloud customer?
Start for Free >
Upgrade in MyJFrog >
What's New in Cloud >

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »


The Matrix native step enables your pipeline to repeatedly execute the same set of actions in a variety of configurations and runtime environments, with each variant executing as an independent “steplet.” These steplets can, when configured  execute in parallel on multiple build nodes. On completion of all steplets, Pipelines aggregates the result status, giving the appearance of a single step.

Common use cases for Matrix steps are:

  • Splitting a large test suite into smaller units, executing them in parallel to reduce total execution time.
  • Testing against multiple values of environment variables or multiple runtime images.

Page Contents

Single Dimension Matrix

The Matrix step is for performing the same operation multiple times, but with different settings each time. This could mean pushing the same Docker image to different registries, or executing the same set of unit tests with different test values.

For example, we might want to perform the same test on a completed build with different sets of values for animalmineral, and vegetable.




Variation 1dogcopper


Variation 2goatiron


Variation 3lizardlead<null>

This example pipeline triggers on any change to the BuildInfo resource produced by another pipeline. The Matrix step performs the same execution actions in parallel steplets, with each using a different set of animalmineral, and vegetable values from the collection specified in the stepletMultipliers:environmentVariables block.

  - name: Matrix_Single_Pipeline
      - name: matrix_example
        type: Matrix
        stepMode: Bash
            - name: CompletedBuildInfo
          environmentVariables:             # Sets of environment variables for steplets
            - animal:    dog                # - Set 1
              mineral:   copper
              vegetable: carrot
            - animal:    goat               # - Set 2
              mineral:   iron
              vegetable: broccoli
            - animal:    lizard             # - Set 3
              mineral:   lead          
            - echo "Executing matrix step on ${steplet_id}"
            - echo "Variation animal = ${animal}, mineral = ${mineral}, vegetable = ${vegetable}"

When successfully executed, the run log of the pipeline shows the set of steplets executed by the Matrix step, along with their individual success status and the set of values used for the Matrix Combination.

Two-Dimension Matrix

A Matrix step can also perform the repeat the same operations in multiple runtime environments. For example, running tests in Java and Javascript, or in different release versions of the same runtime.

This can be done as a single-dimension matrix (performing a single, fixed set of actions in each runtime) or as a two-dimension matrix (performing different actions with different configurations in multiple runtimes).

If we modify the single matrix example above to run in both Java and Javascript runtimes, it will execute in a total of 6 steplets: in 2 runtimes for each of 3 sets of environment variables:

RuntimeSet 1Set 2Set 3
java 13.0dog, copper, carrrotgoat, iron, broccolilizard, lead, <null>
node 8.17.0dog, copper, carrrotgoat, iron, broccolilizard, lead, <null>

Matrix Pipeline Example

The following example pipeline can be found in the  JFrog GitHub repository. You can fork this repo to your own GitHub account to try on your own installation of Pipelines.

The two-dimension matrix pipeline provides a simplified example of running tests in modules in different runtime environments. It peforms basic functionality tests on four different math operation modules, repeating these tests in different release versions of nodejs.


The first step of the pipeline will trigger on any change to the example GitHub repo, which also houses the test files. So any change to the tests or the pipeline will trigger a new run of the pipeline.

If you have forked the example, you will need to change the path and integration name as noted in the comments.

  - name: sample_code
    type: GitRepo
      path: jfrog/jfrog-pipelines-matrix-example      # Change to your own path
        include: ^master$
      gitProvider: jfrog_github                       # Change to your own GitHub integration name

PreMatrix Step

The PreMatrix generic step is an optional step for performing preamble operations. It may be used to prepare a build environment for execution of a Matrix step.

When a PreMatrix step is used in a pipeline, it is guaranteed that a subsequent Matrix step will execute in the same build node, so that whatever is created in the build environment by the PreMatrix step will be available to the Matrix step.

Our example PreMatrix step loads the npm package dependencies that will be needed by the steplets.

PreMatrix Example Step
      - name: setup
        type: PreMatrix
            - name: sample_code
            - echo "Preparing the code base"
            - pushd "${res_sample_code_resourcePath}/app"
            - npm install
            - popd 
            - mkdir -p app
            - cp -r "${res_sample_code_resourcePath}/app/." ./app/

Matrix Step

The Matrix step executes the test cases for each module in multiple versions of the nodejs runtime. The modules are specified as environment variables in stepletMultipliers , which also specifies the runtimes.

Matrix Example Step
      - name: test
        type: Matrix
        stepMode: Bash
            - name: setup
            - module: mod_1
            - module: mod_2
            - module: mod_3
            - module: mod_4
            - type: image
                  language: node
                    - 12
            - type: image
                  language: node
                    - 8.17.0                    
            - pushd ./setup/app
            - MODULE="$module" npm run test
            - popd
            - save_tests ./setup/app/reports

PostMatrix Step

When a PostMatrix step is used in a pipeline, it is guaranteed to execute in the same build node as the prior Matrix step, so that the PostMatrix step can aggregate any information from the build environment.

In the example pipeline, the PostMatrix step aggregates all the test reports.

PostMatrix Step Example
      - name: output
        type: PostMatrix
            - name: test
            - echo "Executing the output step"
            - ls -ltr ./test/setup/app/reports
            - save_tests ./test/setup/app/reports


When the example pipeline is loaded and run, the Matrix step executes eight steplets. The run log for each steplet, including saved test results, can be viewed from the pipeline's run history.

The run log of the PostMatrix step shows the aggregated results of all steplets.

  • No labels
Copyright © 2022 JFrog Ltd.