Single Dimension Matrix
The Matrix step is useful 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 animal, mineral, and vegetable.
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 animal, mineral, and vegetable values from the collection specified in the
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.
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).
|Runtime||Set 1||Set 2||Set 3|
|java 13.0||dog, copper, carrot||goat, iron, broccoli||lizard, lead, <null>|
|node 8.17.0||dog, copper, carrot||goat, iron, broccoli||lizard, 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 performs 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.
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.
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.
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.
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.