2

I am building a test system with Jenkins with multiple slave nodes. I have multiple test cases where each of them take at more than 15 minutes to run.

I want to make the system in a way that when I start tests Jenkins running each test case in a node which is free and at the end collects and summarizes the test results.

I have opened a Jenkins job which is general test-case job and it is parametrized where the parameter is the "test name". But I see that Jenkins is executing the jobs sequentially.

How can I configure Jenkins to run builds for the same job (with different parameters) in parallel?

Ben Hirschberg
  • 1,410
  • 1
  • 12
  • 17

2 Answers2

1

simple syntax for parallel:

pipeline {
stages {
    stage('Run Tests In Parallel') {
        parallel {
            stage('Projects Test 1') {
                agent {
                    node { label "your jenkins label" }
                }
                steps{
                   script {
                        your test 1
                   }
                }
                post{
                    always {
                        script {
                            echo ' always'                                
                        }
                    }

                }
            }

            stage('Projects Test 2') {
                agent {
                    node { label "your jenkins label" }
                }
                steps{
                   script {
                        your test 2
                   }
                }
                post{
                    always {
                        script {                                
                            echo ' always'                             

                        }
                    }

                }
            }
        }   
    }
}

}

0

Hi you can use parallel stages in jenkins which runs parallely. also use agent any at each stage so it will use any free node.

Check Parallel Stages document for more info

Amit Nanaware
  • 3,203
  • 1
  • 6
  • 19
  • I have seen this. It indeed makes builds parallel. I'm trying to find out how to generate the script automatically from the list of tests I have. I'm trying to avoid the situation where I need to add a new test in two places (one in the code, the other in Jenkins). – Ben Hirschberg Jan 20 '19 at 07:07
  • I have not used this myself yet, but this plugin looks promising: https://plugins.jenkins.io/parallel-test-executor/ – burtmacklin16 Aug 17 '21 at 01:49