简体   繁体   English

使用不同的 maven 并行运行 Jenkins 作业

[英]Running Jenkins job with different maven opts in parallel

community.社区。 I would like to run Jenkins job, same job but with diferent maven opts values and in parallel.我想运行 Jenkins 作业,相同的作业但具有不同的 maven opts 值并并行运行。 How can i achieve that?我怎样才能做到这一点? I was trying to use different Jenkins plugins, but with no luck.我试图使用不同的 Jenkins 插件,但没有成功。 Trying to configure pipelines using groovy scripts, but i am so amateur that i can't figure out how to achieve what i want.尝试使用 groovy 脚本配置管道,但我太业余了,不知道如何实现我想要的。 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.目标是并行运行相同的 jenkins 作业,但唯一必须不同的是我的测试应该运行的环境。 Maybe there is already a solution so you could point me to that.也许已经有一个解决方案,所以你可以指出我。

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"
                        }
                    }
                }
            }
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM