从詹金斯管道作业触发器运行并行构建,并在其他项目上等待相同的作业

时间:2020-05-05 19:43:51

标签: jenkins groovy jenkins-pipeline jenkins-job-dsl

我有这个测试代码,它按预期在build_servers节点上的不同执行程序上运行2个构建。

pipeline {
    agent { label 'myserver' }
    stages {
        stage('1') {
            steps {
                script {
                    def tests = [:]
                    for (f in [ 'x', 'y' ]) {
                        tests["${f}"] = {
                            node('build_servers') {
                                stage('Clean Workspace') {
                                     echo "cleaning up Ws ${f}"
                                     step([$class: 'WsCleanup'])
                                }
                                stage('create Wspace txt file') {
                                        script {
                                            props="Wspace=${workspace}"
                                            dir ( 'wspace') {
                                                    writeFile file: 'params.txt', text: props
                                            }
                                        }
                                }
                                stage('Run other job') {
                                    script {
                                        println('calling other project')
                                        props = readProperties file: "wspace/params.txt"
                                           file_params = props.collect {
                                                string(name: it.key, value: it.value)
                                        }
                                        build job: "other_job2", parameters: file_params, wait: true, propagate: true
                                    }
                                }
                            }
                        }
                    }
                    parallel tests
                }
            }
        }
    }
}

我希望它在other_job2上触发2个不同的版本,但是它只提交一个作业,而两个tests['x'] and tests['y']都等待相同的作业完成,为什么?是否不应该在other_job2项目中创建2个不同的工作,一个为x,另一个为y

0 个答案:

没有答案