Home > OS >  Running Jenkins job with different maven opts in parallel
Running Jenkins job with different maven opts in parallel

Time:10-01

community. I would like to run Jenkins job, same job but with diferent maven opts values and in parallel. How can i achieve that? I was trying to use different Jenkins plugins, but with no luck. Trying to configure pipelines using groovy scripts, but i am so amateur that i can't figure out how to achieve what i want. The goal is to run same jenkins job in parallel, but the only thing that must be different is environment where my tests should run. Maybe there is already a solution so you could point me to that.

CodePudding user response:

You should be able to use parallel blocks for this. Following is a sample.

pipeline {
    agent none
    stages {
        stage('Run Tests') {
            parallel {
                stage('Test On Dev') {
                    agent {
                        label "IfYouwantToChangeAgent"
                    }
                    steps {
                        sh "mvn clean test -Dsomething=dev"
                    }
                    post {
                        always {
                            junit "**/TEST-*.xml"
                        }
                    }
                }
                stage('Test On QA') {
                    agent {
                        label "QA"
                    }
                    steps {
                        sh "mvn clean test -Dsomething=qa"
                    }
                    post {
                        always {
                            junit "**/TEST-*.xml"
                        }
                    }
                }
            }
        }
    }
}
  • Related