• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • pipeline
    • Jenkins ver. 1.606
      Workflow 1.5

      Consider the following script:

      node {  
          fn("This should only be one string")
      }
      
      def fn (String... strs) {
          echo "${strs.size()}"
      }
      

      This results in the following output:

      Running: Allocate node : Body : Start
      Running: Print Message
      30
      Running: Allocate node : Body : End
      Running: Allocate node : End
      Running: End of Workflow
      Finished: SUCCESS
      

      Under a groovy console the result is as we'd expect, there is one String in the array of Strings.

      def fn (String... strs) {
          println "${strs.size()}"
      }
      
      fn("This should only be one string")
      return
      

      Result:

      1
      

      I'm guessing this is just a bug?
      In the meantime is there a workaround? I'd like a function to handle an array of strings, and need to loop through the Strings, not individual characters.

          [JENKINS-27893] Varargs mishandled in Groovy CPS

          Thomas Dalton created issue -
          Jesse Glick made changes -
          Labels Original: jenkins workflow New: groovy
          Jesse Glick made changes -
          Assignee Original: Jesse Glick [ jglick ] New: Kohsuke Kawaguchi [ kohsuke ]
          Priority Original: Minor [ 4 ] New: Major [ 3 ]
          Summary Original: String arrays, or variable args passed to functions don't seem to work New: Varargs mishandled in Groovy CPS
          Jesse Glick made changes -
          Link New: This issue is blocking JENKINS-25979 [ JENKINS-25979 ]
          Kohsuke Kawaguchi made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 162486 ] New: JNJira + In-Review [ 196963 ]
          Andrew Bayer made changes -
          Component/s New: pipeline-general [ 21692 ]
          Andrew Bayer made changes -
          Component/s Original: workflow-plugin [ 18820 ]

            kohsuke Kohsuke Kawaguchi
            tomjdalton Thomas Dalton
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: