Grouping and decorating groups of parameters in Jenkins

后端 未结 2 1957
盖世英雄少女心
盖世英雄少女心 2021-02-02 01:38

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

2条回答
  •  爱一瞬间的悲伤
    2021-02-02 01:51

    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

提交回复
热议问题