Jenkins pipeline 并行执行任务流

笔者在《Jenkins 在声明式 pipeline 中并行执行任务》一文中介绍了如何在声明式 pipeline 中执行并行的任务。前一段时间,Jenkins 发布了 1.3 版的声明式 pipeline(declarative pipeline),这个版本继续增强了并行执行任务的能力:并行执行的任务可以是个任务流。官方称这一功能为 "sequential stages",本文将解释 "sequential stages",并通过 demo 演示其用法。

之前的任务并行方式

就是笔者在《Jenkins 在声明式 pipeline 中并行执行任务》一文中介绍的方式,我们在一个 stage 中设置多个子 stage 并行执行:

stages { stage('Stage1') { ... } stage('并行执行的 Stage') { parallel { stage('Stage2.1') { agent { label "test1" } steps { echo "在 agent test1 上执行的并行任务 1." } } stage('Stage2.2') { agent { label "test2" } steps { echo "在 agent test2 上执行的并行任务 2." } } } } stage('Stage3') { ... } }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zygfsp.html