E.g. Below code is used for single select value
choice{
choices: 'Box\nOneDrive\nSharePointOnline\nGmail\nGDrive\nGenericS3',
defaultValue: 'box',
description: 'Connector to build',
name: 'On_Cloud_Devices_To_Test'
}
I would use booleanParam's. Then the user can tick all the required options.
booleanParam(defaultValue: false, name: 'ALL', description: 'Process all'),
booleanParam(defaultValue: false, name: 'OPTION_1', description: 'Process option 1'),
booleanParam(defaultValue: false, name: 'OPTION_2', description: 'Process options 2'),
You could use "Extended Choice Parameter" plugin, as this page suggests.
Sinse the parameter list is very long, you may wrap it into a function:
import com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition
def checkBox (String name, String values, String defaultValue,
int visibleItemCnt=0, String description='', String delimiter=',') {
// default same as number of values
visibleItemCnt = visibleItemCnt ?: values.split(',').size()
return new ExtendedChoiceParameterDefinition(
name, //name,
"PT_CHECKBOX", //type
values, //value
"", //projectName
"", //propertyFile
"", //groovyScript
"", //groovyScriptFile
"", //bindings
"", //groovyClasspath
"", //propertyKey
defaultValue, //defaultValue
"", //defaultPropertyFile
"", //defaultGroovyScript
"", //defaultGroovyScriptFile
"", //defaultBindings
"", //defaultGroovyClasspath
"", //defaultPropertyKey
"", //descriptionPropertyValue
"", //descriptionPropertyFile
"", //descriptionGroovyScript
"", //descriptionGroovyScriptFile
"", //descriptionBindings
"", //descriptionGroovyClasspath
"", //descriptionPropertyKey
"", //javascriptFile
"", //javascript
false, //saveJSONParameterToFile
false, //quoteValue
visibleItemCnt, //visibleItemCount
description, //description
delimiter //multiSelectDelimiter
)
}
Then use it as follows:
def testParam = checkBox("opt", // name
"opt1,opt2,opt3", // values
"opt1", //default value
0, //visible item cnt
"Multi-select", // description
)
properties(
[parameters([testParam])]
)
node {
echo "${params.opt}"
}
Jenkins Build with Parameters:
This is scripted pipeline syntax by the way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With