Jenkins' Declarative Pipeline with Advanced Selection Option
I tried to implement my first declarative pipeline with Jenkins so that the job parameter definitions in SCM can also be put.
I wanted to migrate an existing work with an advanced selection option. Unfortunately, I was unable to add it to the {...} parameters section of my script.
From the plugin page: https://wiki.jenkins-ci.org/display/JENKINS/Extended+Choice+Parameter+plugin I found a comment that said this should be possible:
import com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition
def type = "PT_JSON"
def groovyScript = null
def propertyValue = null
def projectName = null
def propertyFile = null
def groovyScriptFile = "/path_to/script.groovy"
...
def extendedChoice = new ExtendedChoiceParameterDefinition(name,
type,
propertyValue,
projectName,
propertyFile,
groovyScript,
.....
input message: 'Param1', parameters: [extendedChoice]
Unfortunately it didn't work for me. "Input required" gave an unspecified error. While I could live with the "incoming message" solution, it was not what I was looking for in the first place. I want to add this parameter to the parameters section as already mentioned. But I cannot find the place where it is described. Any suggestions how to proceed, or perhaps alternative approaches / plugins as well?
source to share
Go to the page http://jenkins-url.com/pipeline-syntax
in the dropdown "Select Sample step
to select properties
For This project is parameterized
checkbox with This project is parameterized
then you can select Add parameter
Extended Choice Parameter
and generate a wobble for it. This is for your pipeline."
source to share
This is what I have used and tested successfully for one parameter, you may need to convert it for Json
com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition extch =new com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition( "NAME", "PT_SINGLE_SELECT", "VALUE, a, b", null, null, null, null, null,null, null,null,null, null, null, null,null, null, null,null, null, null, null, null, null, null,null,false,false,2,"DESC", "," )
source to share