-
Bug
-
Resolution: Unresolved
-
Major
-
None
The normal script supports returning a list of elements such as
return ["Option 1", "Option 2"]
but when a pipeline is run by a timer or automatically in case of a multi branch pipeline then the script part does not get evaluated and falls back to the fallbackScript.
Unfortunately returning a list of elements does not work in fallbackScript. Even though the examples showing a list being returned, only the first element in the list is taken. We have to join the elements to one string but this causes other issues down the line.
return ["Option 1,Option 2"]
[JENKINS-71579] fallbackScript only returns first element of array
Description |
Original:
The normal script supports returning an list of elements such as
{code:java} return ["Option 1", "Option 2"] {code} but when a pipeline is run by a timer or automatically in case of a multi branch pipeline then the script part does not get evaluated and falls back to the fallbackScript. Unfortunately returning a list of elements does not work in fallbackScript. Even though the examples showing a list being returned, only the first element in the list is taken. We have to join the elements to one string but this causes other issues down the line. {code:java} return ["Option 1,Option 2"] {code} |
New:
The normal script supports returning a list of elements such as
{code:java} return ["Option 1", "Option 2"] {code} but when a pipeline is run by a timer or automatically in case of a multi branch pipeline then the script part does not get evaluated and falls back to the fallbackScript. Unfortunately returning a list of elements does not work in fallbackScript. Even though the examples showing a list being returned, only the first element in the list is taken. We have to join the elements to one string but this causes other issues down the line. {code:java} return ["Option 1,Option 2"] {code} |
The cause appears to be originated in
JENKINS-61068, when no value is selected in the Active Choices parameters, the first value is returned. This is quite counterintuitive because I would expect to get an empty list when there is no values marked as selected, rather than getting an arbitrary value.