Ben Hirschberg
Ben Hirschberg

Reputation: 1500

How to configure Jenkins to run my test cases in parallel?

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?

Upvotes: 2

Views: 9298

Answers (2)

Alon Rosenhek
Alon Rosenhek

Reputation: 26

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'                             

                        }
                    }

                }
            }
        }   
    }
}

}

Upvotes: 1

Amit Nanaware
Amit Nanaware

Reputation: 3346

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

Upvotes: 0

Related Questions