詹金斯平行管道

时间:2017-03-17 14:45:28

标签: jenkins jenkins-pipeline

我有一个管道脚本,目前按顺序执行所有操作:

node('virtual'){
    stage('setup'){...}
    stage('build'){...}
    stage('test'){...}
    stage('clean'){...}
}
node('real'){
    stage('setup'){...}
    stage('build'){...}
    stage('test'){...}
    stage('clean'){...}
}

如果我想让它并行,最好的方法是什么?我知道阶段不应该/不能在并行语句中,但我需要所有这些阶段在同一节点上发生。每个节点的命令不同。

这是否可以接受?我确实需要Build的编译输出才能在Test中访问,如果我不需要它,我想最小化checkout scm,除了第一个。

stage('setup'){
    parallel(
        virtual:{
            node('virtual'){
                // do work
                // stash what is needed
            }
        },
        real:{
            node('real'){
            // do work
            // stash what is needed
            }
        })
}
stage('setup'){
    parallel(
        virtual:{
            node('virtual'){
                //unstash setup
                // do work
                // stash what is needed
            }
        },
        real:{
            node('real'){
            // do work
            // stash what is needed
            }
        })
}
// continue for the rest...

0 个答案:

没有答案