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.
Resources
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.
resources:
- name: sample_code
type: GitRepo
configuration:
path: jfrog/jfrog-pipelines-matrix-example # Change to your own path
branches:
include: ^master$
gitProvider: jfrog_github # Change to your own GitHub integration namePreMatrix 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.
Our example PreMatrix step loads the npm package dependencies that will be needed by the steplets.
PreMatrix Example Step
pipelines:
- name: myPipeline
steps:
- name: setup
type: PreMatrix
configuration:
inputResources:
- name: sample_code
execution:
onExecute:
- 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
configuration:
inputSteps:
- name: setup
stepletMultipliers:
environmentVariables:
- module: mod_1
- module: mod_2
- module: mod_3
- module: mod_4
runtimes:
- type: image
image:
auto:
language: node
versions:
- 12
- type: image
image:
auto:
language: node
versions:
- 8.17.0
execution:
onExecute:
- pushd ./setup/app
- MODULE="$module" npm run test
- popd
onComplete:
- save_tests ./setup/app/reportsPostMatrix Step
The PostMatrix generic step is an optional step for performing post-execution tasks following a Matrix step.
In the example pipeline, the PostMatrix step aggregates all the test reports.
PostMatrix Step Example
- name: output
type: PostMatrix
configuration:
inputSteps:
- name: test
execution:
onExecute:
- echo "Executing the output step"
- ls -ltr ./test/setup/app/reports
- save_tests ./test/setup/app/reportsWhen 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.