按顺序运行 Jenkins 并行任务 [英] Running Jenkins parallel tasks sequentially

查看:23
本文介绍了按顺序运行 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:

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

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

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