Varargs mishandled in Groovy CPS

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      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.

            Assignee:
            Kohsuke Kawaguchi
            Reporter:
            Thomas Dalton
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: