如何在jenkins管道中并行运行两个分支代码?

时间:2019-01-17 10:36:20

标签: jenkins jenkins-pipeline newman

我需要在管道中并行运行newman代码。我在运行纽曼代码时遇到了这个问题:

parallel firstBranch: {
node{

       sh "newman run 'XYZ.json'  --insecure"    


    }
},
secondBranch
    node{
sh "newman run 'XYX.json'  --insecure"
}    
},
failFast: true|false

我得到的错误代码为:

hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: org.jenkinsci.plugins.docker.workflow.Docker.call() is applicable for argument types: (org.jenkinsci.plugins.workflow.cps.CpsClosure2) values: [org.jenkinsci.plugins.workflow.cps
Possible solutions: wait(), any(), wait(long), each(groovy.lang.Closure), any(groovy.lang.Closure), grep()

1 个答案:

答案 0 :(得分:0)

您的管道中有语法错误,例如 secondBranch,不包含“:{” 您可以尝试像从Jenkins文档中摘录的以下示例:

   stages {
    stage('Run Tests') {
        parallel {
            stage('Test On Windows') {
                agent {
                    label "windows"
                }
                steps {
                    bat "run-tests.bat"
                }
                post {
                    always {
                        junit "**/TEST-*.xml"
                    }
                }
            }
            stage('Test On Linux') {
                agent {
                    label "linux"
                }
                steps {
                    sh "run-tests.sh"
                }
                post {
                    always {
                        junit "**/TEST-*.xml"
                    }
                }
            }
        }
    }
}