How can I use the advanced parameter select plugin in the Jenkins pipeline script?

The advanced parameter selection plugin is great and I use it in jobs configured through the user interface https://wiki.jenkins-ci.org/display/JENKINS/Extended+Choice+Parameter+plugin

However, I am struggling to get it working in the Jenkinsfilescript pipeline . It seems that the advanced parameter selection plugin is not yet fully compatible with Pipeline scripts, as the Jenkins pipeline syntax generator generates the following snippet:

parameters([<object of type com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition>])

If I create the parameters manually, I get the same behavior as indicated at https://issues.jenkins-ci.org/browse/JENKINS-32188

org.kohsuke.stapler.NoStaplerConstructorException: There no @DataBoundConstructor on any constructor of class 

Does anyone know of any workarounds that can work around the problem ExtendedChoiceParameterDefinitionwithout using it @DataBoundConstructor?

  • Jenkins 2.19.2
  • Plugin for advanced parameter selection 0.75
+16
source share
4 answers

Here is my workaround for this pb:

https://gist.github.com/jgraglia/44a7443847cff6f0d87387a46c7bb82f

i.e.: manually create a parameter by declaring all arguments

I was able to add the multi checklist parameter to my pipeline with this.

+5
source

Like mkobit, it is currently not possible to use the advanced select plugin as a build parameter.

What I like to use as a workaround is a design similar to 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<String, String>
}

echo "${result.SomeBoolean}, ${result.SomeChoice}, ${result.SomeText}"

. .

+1

2 2019 : https://github.com/jenkinsci/extended-choice-parameter-plugin/pull/25

, , :

properties([
    parameters([
        extendedChoice( 
            name: 'PROJECT', 
            defaultValue: '', 
            description: 'Sélectionnez le projet à construire.', 
            type: 'PT_SINGLE_SELECT', 
            groovyScript: valueKeysScript,
            descriptionGroovyScript: valueNamesScript
        )
    ])
])

, . "type", PT_*.

0

: ( -)

node {
    properties([
        buildDiscarder(
            logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '5')), 
            parameters([
                    [$class: 'ExtensibleChoiceParameterDefinition', 
                        choiceListProvider: [
                           $class: 'TextareaChoiceListProvider', 
                           choiceListText: 'foo\nbar',
                           defaultChoice: 'bar',
                           addEditedValue: false,
                       ], 
                       description: 'blah blah blah blah', 
                       editable: true, 
                       name: 'choose_mnt'
                    ], 
                    booleanParam(defaultValue: false, description: '[TO DO]', name: 'include_installers')
                ]), 
                pipelineTriggers([])
            ])

    stage('Do Work') {
        print("-----------------------------------")
        print("Build ID: ${currentBuild.id}")
        sh 'date'
        sh 'pwd'
    }
}
-2

Source: https://habr.com/ru/post/1682838/


All Articles