I have a Jenkins job that I need to set a parameter, if the user choose "EXISTING" to use an existing file, then the next parameter should be a dropdown with a list the existing file names for user to choose. If the user choose "NEW", the next parameter should be a string parameter for user to enter a file name.
I can not find how to use Active Choices Parameter and Active Choices Reactive Parameter to accomplish this. Maybe I am looking at the wrong direction?
For the first parameter CHOICE, I have the groovy script:
return [
"EXISTING",
"NEW"
]
for the second parameter FILES, I have this:
if (CHOICE.equals("EXISTING")) {
return ["file1","file2",..."filen"]
}
else if (CHOICE.equals("NEW")) {
return []
}
This does not do what I want.
How do I make the second parameter to allow user's input when the first parameter is "NEW"? Or to make the code to use two additional different parameters, one to show the existing file list when user choose EXISTING and one to let user enter a file name if the user choose NEW?
After I pick up the parameter values from above, I will pass them to a ansible playbook in the Build section.
Thanks!