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.

1 Answer 1

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/

4
  • 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
    Commented Aug 19, 2021 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
    Commented Aug 19, 2021 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
    Commented Aug 19, 2021 at 13:15
  • Finally I divide my XML file in to 2 files and add two different jobs
    – ChathuD
    Commented Aug 24, 2021 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.