Grouping and decorating groups of parameters in Jenkins

三世轮回 提交于 2019-12-03 09:57:33

问题


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?


回答1:


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




回答2:


for dsl you can specify:

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

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

pipelineJob("Foo-job") {
    description("FOO with separators")

    parameters {
        parameterSeparatorDefinition {
            name('FOO_1')
            separatorStyle(separatorStyleCss)
            sectionHeader('FOO_1')
            sectionHeaderStyle(sectionHeaderStyleCss)
        }

Don't make the silly mistake of using the name sectionHeaderStyle as per example in your dsl as that will conflict with the constructor!

which you will obviously spot when you see the error: No signature of method: java.lang.String.call() is applicable for argument types: (java.lang.String) values: []



来源:https://stackoverflow.com/questions/44820799/grouping-and-decorating-groups-of-parameters-in-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!