在 Jenkins 中对参数组进行分组和装饰 [英] Grouping and decorating groups of parameters in Jenkins

查看:23
本文介绍了在 Jenkins 中对参数组进行分组和装饰的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个包含很多参数的 Jenkins 流水线作业,我正在寻找一种将它们直观组合在一起的方法,以便它们更容易理解 - 而不是全部扔在那里.我会满足于任何至少暗示这些参数彼此相关的事实.可以是标题,也可以是盒子.是否有任何插件可以帮助我以这种方式装饰我的输入?

解决方案

所以,在网上搜索了很多之后,我终于找到了一个可以解决问题的插件.

我使用 Jenkins 2.61、Pipeline Plugin 2.5 和 Parameter Separator Plugin 1.0 对此进行了测试

I'm writing a Jenkins pipeline job with quite a few parameters and I'm looking for a way to visually group them together so they will be easier to understand -rather than have them all just thrown in there. I'll settle for anything that at least hints a the fact that these parameters are related to each other. Could be a header, could be boxes. Is there any plugin that will help me decorate my inputs this way?

解决方案

So, after much searching the web I finally found a plugin that does the trick. The Parameter Separator Plugin. The wiki page doesn't say how to make it work in a pipeline, but after some trial and error this is how I got it to work. I hope this is useful to others.

String sectionHeaderStyle = '''
    color: white;
    background: green;
    font-family: Roboto, sans-serif !important;
    padding: 5px;
    text-align: center;
'''

String separatorStyle = '''
    border: 0;
    border-bottom: 1px dashed #ccc;
    background: #999;
'''

properties([
    parameters([
        [
            $class: 'ParameterSeparatorDefinition',
            name: 'FOO_HEADER',
            sectionHeader: 'Foo Parameters',
            separatorStyle: separatorStyle,
            sectionHeaderStyle: sectionHeaderStyle
        ],
        string(
            name: 'FOO 1'
        ),
        string(
            name: 'FOO 2'
        ),
        string(
            name: 'FOO 3'
        ),
        [
            $class: 'ParameterSeparatorDefinition',
            name: 'BAR_HEADER',
            sectionHeader: 'Bar Parameters',
            separatorStyle: separatorStyle,
            sectionHeaderStyle: sectionHeaderStyle
        ],
        string(
            name: 'BAR 1'
        ),
        string(
            name: 'BAR 2'
        ),
        string(
            name: 'BAR 3'
        )
    ])
])

This is the result:

Edit:

I tested this with Jenkins 2.61, Pipeline Plugin 2.5 and the Parameter Separator Plugin 1.0

这篇关于在 Jenkins 中对参数组进行分组和装饰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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