3

Is there any way to set up a Jenkins job where it will execute part of the test cases in a Node A and other part of the tests in Node B. Technically, I need to reduce my test executing time executing tests in parallel on two different servers (Agents).

In the worst case, I was planing to make two jobs which will run two different text.xml files and those XML files will contain different test classes.

ChathuD
  • 2,149
  • 22
  • 46

1 Answers1

1

In a Jenkins pipeline you can run stages parallel:

    pipeline {
    agent none
    stages {
        stage('Run Tests') {
            parallel {
                stage('Test On agentA') {
                    agent {
                        label "agentA"
                    }
                    steps {
                        sh "run-testsA.sh"
                    }
                    post {
                        always {
                            junit "**/TEST-*.xml"
                        }
                    }
                }
                stage('Test On agentB') {
                    agent {
                        label "agentB"
                    }
                    steps {
                        sh "run-testsB.sh"
                    }
                    post {
                        always {
                            junit "**/TEST-*.xml"
                        }
                    }
                }
            }
        }
    }
}

https://www.jenkins.io/blog/2017/09/25/declarative-1/

Patrick
  • 147
  • 2
  • 12
  • Thanks for the reply. So how does it going to decide which TC are going to run on agent 01 and which TC are going to run on agent 02? – ChathuD Aug 19 '21 at 12:42
  • You have to decide that for him. Most testautomationframeworks/-tools have a way to run a subset of your tests. For example by using tags. – Patrick Aug 19 '21 at 13:06
  • Will you available for a quick screen sharing session with me ,Coz I have so many questions to ask on thus Jenkins PIPELINE which is totaly new to me. – ChathuD Aug 19 '21 at 13:15
  • Finally I divide my XML file in to 2 files and add two different jobs – ChathuD Aug 24 '21 at 09:56