Issue
How to do a multiselect input in a pipeline using Extended Choice Parameter plugin
Environment
- CloudBees CI (CloudBees Core) on modern cloud platforms - Managed controller
- CloudBees CI (CloudBees Core) on traditional platforms - Client controller
- CloudBees Jenkins Platform - Client controller
- Jenkins LTS
- DevOptics
- Extended Choice Parameter plugin
Resolution
Extended Choice Parameter plugin offers many options, which can be easily explored by using The snippet Generator.
Following a couple of examples:
- Scripted Pipeline
import com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition
node {
def multiSelect= new ExtendedChoiceParameterDefinition("name",
"PT_MULTI_SELECT",
"blue,green,yellow,blue",
"project name",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"blue,green,yellow,blue",
"",
"",
"",
"",
"",
"",
"",
"",
false,
false,
3,
"multiselect",
",")
def userInput = input id: 'customID', message: 'Let\'s promote?', ok: 'Release!', parameters: [multiSelect]
echo "Hello: "+ userInput
}
- Declarative Pipeline
pipeline {
agent any
stages {
stage('Example') {
input {
message "Let's promote?"
ok 'Release!'
parameters {
extendedChoice defaultValue: 'blue,green,yellow,blue', description: '', descriptionPropertyValue: 'blue,green,yellow,blue', multiSelectDelimiter: ',', name: 'favColor', quoteValue: false, saveJSONParameterToFile: false, type: 'PT_MULTI_SELECT', value: 'blue,green,yellow,blue', visibleItemCount: 5
}
}
steps {
echo "Your favorite color is ${favColor}"
}
}
}
}
Tested product/plugin versions
The latest update of this article has been tested and verified with:
5 Comments