我可以在Jenkins管道中动态创建阶段吗? [英] Can I create dynamically stages in a Jenkins pipeline?
本文介绍了我可以在Jenkins管道中动态创建阶段吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在声明式管道中启动一组动态测试. 为了更好的可视化目的,我想为每个测试创建一个阶段. 有办法吗?
I need to launch a dynamic set of tests in a declarative pipeline. For better visualization purposes, I'd like to create a stage for each test. Is there a way to do so?
创建一个我知道的阶段的唯一方法是:
The only way to create a stage I know is:
stage('foo') {
...
}
I've seen this example, but I it does not use declarative syntax.
推荐答案
使用脚本化语法,比声明性语法具有更大的灵活性,即使声明性文档和推荐性更高.
Use the scripted syntax that allows more flexibility than the declarative syntax, even though the declarative is more documented and recommended.
例如,可以循环创建阶段:
For example stages can be created in a loop:
def tests = params.Tests.split(',')
for (int i = 0; i < tests.length; i++) {
stage("Test ${tests[i]}") {
sh '....'
}
}
这篇关于我可以在Jenkins管道中动态创建阶段吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文