Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-71579

fallbackScript only returns first element of array

      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

          Joseph Choi added a comment - - edited

          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.

          Joseph Choi added a comment - - edited 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.

          Muhammet added a comment -

          Yes, I would too expect an empty list when using

          return ["Option 1", "Option 2"]
          

          where no item is marked as selected in the fallback script

          I would expect both items if both are marked selected by default in the fallback script

          return ["Option 1:selected", "Option 2:selected"]
          

           

          Muhammet added a comment - Yes, I would too expect an empty list when using return [ "Option 1" , "Option 2" ] where no item is marked as selected in the fallback script I would expect both items if both are marked selected by default in the fallback script return [ "Option 1:selected" , "Option 2:selected" ]  

            kinow Bruno P. Kinoshita
            gubergren Muhammet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: