I have been trying unsuccessfully to get DynamicReferenceParameter of the Active Choice plugin to show previously selected values as list, however it either shows them on one line or it treats each symbol as a new element in the list.
hosts_script = '''
return['host1', 'host2', 'host3']
'''
properties([
parameters([
[$class: 'ChoiceParameter',
choiceType: 'PT_MULTI_SELECT',
description: 'Select one or more hosts',
filterLength: 1,
filterable: true,
name: 'hosts',
randomName: 'choice-parameter-5631314439613978',
script: [
$class: 'GroovyScript',
fallbackScript: [
classpath: [],
sandbox: true,
script:
'return[\'Could not get hosts\']'
],
script: [
classpath: [],
sandbox: true,
script: hosts_script,
]
]
],
[$class: 'DynamicReferenceParameter',
choiceType: 'ET_UNORDERED_LIST',
description: 'These are the selected hosts',
name: 'Selected hosts',
omitValueField: false,
randomName: 'choice-parameter-5693388460832175',
referencedParameters: 'hosts',
script: [
$class: 'GroovyScript',
fallbackScript: [
classpath: [],
sandbox: true,
script:
'return[\'Could not get hosts\']'
],
script: [
classpath: [],
sandbox: true,
script:
"""
//def list = hosts.replaceAll( '"','\\'' )
//List list = hosts.collect{ '\\'' + it + '\\','}
//def list1 = new ArrayList(Arrays.asList(hosts))
List list = hosts.collect{ '\\'' + it + '\\','}
//String list = hosts.inspect()
return list
"""
]
]
]
])
])
I can get this • host1,host2
Or this:
•'h',
•'o',
•'s',
•'t',
•'2',
Where I want this:
• host1
• host2
At the very end you will see what I have been playing with ... the biggest problem for me is that is impossible to use println
to troubleshoot.