Jenkins Pipeline is a suite of plugins that allows creating simple-to-complex build stages for your testing environment on CI. We can use Jenkins Pipeline to run a few stages at the same time and thanks to that parallelize test suite across a few stages to complete tests faster.
In order to run parallel stages with Jenkins Pipeline, we will need a proper Jenkinsfile which represents our delivery pipeline as code via the Pipeline domain-specific language (DSL) syntax.
Another thing we will have to figure out is the problem how to divide our test suite across parallel stages in a way that each subset of test suite executed across all stages will complete work at the same time. It’s important to complete the tests on all stages at a similar time to run our CI build as fast as possible and eliminate bottleneck stage.
How to split test suite evenly across parallel Jenkins stages
To divide our tests across parallel stages we can use Knapsack Pro which allows to dynamically allocate tests across stages (also known as CI nodes). This way we will run our parallelised tests in optimal time.
Here you can learn more how dynamic test suite allocation works and with what else problems it can help.
Jenkinsfile for parallel pipeline
This is Ruby example how to split Cucumber and RSpec test suite. Other test runners like Minitest, Test::Unit etc are available as well at Knapsack Pro:
If you are currently considering the choice between Jenkins and other CI, check out our popular comparison pages: Jenkins vs Github Actions, Drone vs Jenkins, AWS CodeBuild vs Jenkins, and Cloud Build vs Jenkins.