我可以在 Jenkins 管道中动态创建阶段吗? [英] Can I create dynamically stages in a Jenkins pipeline?

查看:27
本文介绍了我可以在 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屋!

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