依次运行Jenkins并行任务 [英] Running Jenkins parallel tasks sequentially

查看:414
本文介绍了依次运行Jenkins并行任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个新的Jenkins管道,并具有一组最终要并行运行的步骤.但是,在开发此管道时,我想强制其顺序运行.我没有看到任何指定并行步骤使用的线程数或类似方法的方法.这是到目前为止的基本代码:

I'm writing a new Jenkins pipeline and have a set of steps that I would eventually like to run in parallel. But while I'm developing this pipeline I'd like to force it to run sequentially. I'm not seeing any way to specify the number of threads a parallel step uses or anything like that. Here is the basic code so far:

node('x') {
    stage('cleanup'){
        def cleanupScripts = [:]
        cleanupScripts[1] = { sh(script: "cleanup1.sh") }
        cleanupScripts[2] = { sh(script: "cleanup2.sh") }
        cleanupScripts[3] = { sh(script: "cleanup3.sh") }
        cleanupScripts[4] = { sh(script: "cleanup4.sh") }
        parallel cleanupScripts
    }
}

我希望能够依次运行这些Shell脚本而无需更改大量代码.

I'd like to be able to run those shell scripts sequentially without changing a lot of code.

推荐答案

您可以像这样使用parallel cleanupScripts代替:

Instead of parallel cleanupScripts you can use like this:

cleanupScripts.each{ key, value ->
    value()
}

这篇关于依次运行Jenkins并行任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆