{ ... script { ....
if (isStartedByUser) {
try {
timeout(time: 60, unit: 'SECONDS') {
def userInput = input(
id: 'userInput', message: 'Please Enter Environment', parameters:
[choice(name: 'environment', choices: tf.join("\n"), description: 'Choose environment you want to deploy this build'),
choice(name: 'debuglevel', choices: "\nINFO\nTRACE\nDEBUG\nWARN\nERROR", description: 'Choose debug level')
]
)
mydir = userInput['environment']
这里
我有这个在Jenkins管道。tf是从一个json导入的列表。目前这个代码片段只允许选择一个单一的选择。我希望能够选择多个选择的环境下拉选择器。
好了,现在我有这个,它的工作!但需要轻微的优化:
def multiSelect= new ExtendedChoiceParameterDefinition("Envs",
"PT_MULTI_SELECT",
tf.join(","),
"project name",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
tf.join(","),
"",
"",
"",
"",
"",
"",
"",
"",
false,
false,
15,
"Available Environments",
",")
def userInput = input(
id: 'userInput', message: 'Please Select terraform params', parameters:
[multiSelect]
)
def userInput2 = input(
id: 'userInput', message: 'Please Select terraform params', parameters:
[choice(name: 'debuglevel', choices: "\nINFO\nTRACE\nDEBUG\nWARN\nERROR", description: 'Choose debug level')
]
)
terraformdir = userInput.split(',')
println "dir ${terraformdir}"
env.TF_LOG = userInput2['debuglevel']
我希望能在同一个屏幕上得到两个输入。
当我做了
def userInput = input(
id: 'userInput', message: 'Please Select terraform params', parameters:
[multiSelect,
choice(name: 'debuglevel', choices: "\nINFO\nTRACE\nDEBUG\nWARN\nERROR", description: 'Choose debug level')
]
)
我不确定如何访问multiSelect的值。
1条答案
按热度按时间q35jwt9p1#
是的,你应该能够,看看here的例子。下面是一个声明性管道的例子。