How can I use the Extended Choice Parameter plugin in a Jenkins pipeline script?

前端 未结 6 1903
暖寄归人
暖寄归人 2021-02-02 09:01

The Extended Choice Parameter plugin is great and I use it in jobs configured via the UI https://wiki.jenkins-ci.org/display/JENKINS/Extended+Choice+Parameter+plugin

How

6条回答
  •  别跟我提以往
    2021-02-02 09:33

    Like mkobit said it is currently not possible to use the extended choice plugin as a build parameter.

    What I like to use as a workaround is a construct like the following

    timeout(time: 5, unit: TimeUnit.MINUTES) {
        def result = input(message: 'Set some values', parameters: [
            booleanParam(defaultValue: true, description: '', name: 'SomeBoolean'),
            choice(choices: "Choice One\nChoice Two", description: '', name: 'SomeChoice'),
            stringParam(defaultValue: "Text", description: '', name: 'SomeText')
        ]) as Map
    }
    
    echo "${result.SomeBoolean}, ${result.SomeChoice}, ${result.SomeText}"
    

    And call it in the beginning of my pipeline. You then get asked for these inputs shortly after your build starts.

提交回复
热议问题