按顺序运行 Jenkins 并行任务

编程入门 行业动态 更新时间:2024-10-23 07:30:14
本文介绍了按顺序运行 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 并行任务

本文发布于:2023-11-24 04:23:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1623959.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:顺序   Jenkins

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!