Issue
How to do a multiselect input in a pipeline using 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}" } } } }
This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.