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

vararg closure does not work in pipeline script

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • groovy-plugin
    • Jenkins 2.150.1
      Pipeline: Groovy plugin 2.62

      Defining closure with vararg does not work in a pipeline script:

      def fn = {String... args -> echo args.toString()}
      fn('one', 'two', 'three')
      
      Output:
      one
      

      Only workaround I can find is to not use closure:

      def fn(String... args){echo args.toString()}
      fn('one', 'two', 'three')
      
      Output:
      [one, two, three]
      

            vjuranek vjuranek
            shangdi Di Shang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: