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

ComposedClosure not working with List.each

    XMLWordPrintable

Details

    Description

      The following Pipeline code does not yield the expected result.

      def xs = ['1', '2', '3']
      def fix = { it + '-webapp' } >> { echo "ha ${it}" }
      echo "${fix('foobar')}" // works
      xs.each { echo "${it}" } // works
      xs.each fix // fails
      

      Results in the following output:

      [Pipeline] echo
      foobar-webapp
      [Pipeline] echo
      1
      [Pipeline] echo
      2
      [Pipeline] echo
      3
      [Pipeline] End of Pipeline
      Finished: SUCCESS
      

      So calling the ComposedClosure works, calling each with a simple Closure works, but calling each with the ComposedClosure does not work.

      The expected result is that calling each with the ComposedClosure yields:

      [Pipeline] echo
      1-webapp
      [Pipeline] echo
      2-webapp
      [Pipeline] echo
      3-webapp
      

      Attachments

        Issue Links

          Activity

            pmr Philipp Moeller created issue -
            abayer Andrew Bayer made changes -
            Field Original Value New Value
            Link This issue relates to JENKINS-44924 [ JENKINS-44924 ]
            abayer Andrew Bayer made changes -
            Assignee Andrew Bayer [ abayer ]
            abayer Andrew Bayer made changes -
            Labels groovy pipeline complex-cps-code groovy pipeline triaged-2018-11
            abayer Andrew Bayer made changes -
            Assignee Andrew Bayer [ abayer ]

            People

              Unassigned Unassigned
              pmr Philipp Moeller
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: