Is there a way to conditionally enable/disable a string input parameter? With the Active Choices plugin I see that selection inputs, like dropdowns, radio buttons, etc. can be controlled with arbitrary groovy code, but I need to control an input where user is permitted to enter any value.
Can you expound more on the purpose of doing this? Would a default value not work? What is the use case you are trying to solve (there might be a different way of accomplishing what you want to do).
Yes, hereās the use case. I support a job for our development team to run validation tests in a ānear productionā environment. There are two typical test suites, but sometimes a third option, for a user to type the name of a less-common test case, is needed. The dozens of options (even with a filter) in the drop-down isnāt practical, and I canāt know all the items in the list as recent checkins could have added/removed test cases. In summary, our users want this on the Build With Parameters page:
Input #1: Drop down
Test Class: MostCommonTestA (default), CommonTestB, OTHER
Input #2: Staring input, disabled unless Input #1 == OTHER
Enter Test Class:
What we have today is both inputs active. Often users enter something in Input#2, but forget to set Input#1 to āOTHERā, to prevent that mistake, weād like to have Input#2 disabled until Input#1 has been set. I thought that Active Choice plugin could do this, but I donāt see how.
I think you would want an active choice reference parameter and return different input html depending on the drop down value. The active choice parameter plugin page has some examples of the reference parameter. So, since it is a reference parameter, you should have access to the current value of the drop down (also an active choice parameter) and be able to return different HTML based on the value (e.g., a hidden input element when a common test case is selected and a normal input text box when OTHER is selected).
Thanks for the suggestions, I tried putting it in to practice, but I still must be missing something. Hereās two attempts which seems close but still donāt work.
First one gives me an input box, but does NOT let me type in it!
Second displays the html input but doesnāt set the build parameterās value with what I type. I tried wrapping the with various combinations of but always got same behaviour, not able to pass what I type to the value of the parameter.
Hereās the two āalmost solutionsā, does anyone see what I might be missing??
Active Choices Reactive Reference Parameter:
Name: JUNIT_TEST_CLASS_OTHER1
Choice Type: Input Text Box
Referenced Parameter: JUNIT_TEST_CLASS
Groovy Script:
if (JUNIT_TEST_CLASS.equals(āOtherā)) {
return āEnter classname hereā
} else {
return āDisabledā
} Result: Displays an input but will not let me type in it!
Active Choices Reactive Reference Parameter:
Name: JUNIT_TEST_CLASS_OTHER2
Choice Type: Formatted HTML
Groovy Script:
if (JUNIT_TEST_CLASS.equals(āOtherā)) {
return āā"
āāā;
} else {
return āāāNot activeāā";
} Result: Displays a text box, but does not send the contents to the build script, the parameter Iām trying to set has empty value.