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

Pipeline parallel map not supporting curried closures

      When executing a curried closure in parallel the output appears to be cached (see the output for the spam branch below).

      Example pipeline:

      def example_c = { input -> node { echo "$input" } }
      def map = [:]
      map['spam'] = example_c.curry('spam')
      map['eggs'] = example_c.curry('eggs')
      parallel map
      

      Output:

      [Pipeline] parallel
      [Pipeline] [spam] { (Branch: spam)
      [Pipeline] [eggs] { (Branch: eggs)
      [Pipeline] [spam] node
      [spam] Running on java8-jenkins-ec2-slave (i-a541b5be) 
      [Pipeline] [eggs] node
      [Pipeline] [spam] {
      [eggs] Running on java8-jenkins-ec2-slave (i-a541b5be) 
      [Pipeline] [spam] echo
      [spam] eggs
      [Pipeline] }
      [Pipeline] [eggs] {
      [Pipeline] // node
      [Pipeline] }
      [Pipeline] [eggs] echo
      [eggs] eggs
      [Pipeline] }
      [Pipeline] // node
      [Pipeline] }
      [Pipeline] // parallel
      [Pipeline] End of Pipeline
      

          [JENKINS-38052] Pipeline parallel map not supporting curried closures

          Ben Fortuna added a comment -

          Also note that the equivalent script run in the Script Console works as expected:

          def example_c = { input -> println "$input" }
          def map = [:]
          map['spam'] = example_c.curry('spam')
          map['eggs'] = example_c.curry('eggs')
          map.keySet().each { key ->
            map[key]()
          }
          

          Result

          spam
          eggs
          Result: [spam, eggs]
          

          Ben Fortuna added a comment - Also note that the equivalent script run in the Script Console works as expected: def example_c = { input -> println "$input" } def map = [:] map[ 'spam' ] = example_c.curry( 'spam' ) map[ 'eggs' ] = example_c.curry( 'eggs' ) map.keySet().each { key -> map[key]() } Result spam eggs Result: [spam, eggs]

          Jacob Keller added a comment -

          I think this is similar to https://issues.jenkins-ci.org/browse/JENKINS-38268 and doesn't require use of curried closures, but just closures within parallel in general.

          Jacob Keller added a comment - I think this is similar to https://issues.jenkins-ci.org/browse/JENKINS-38268 and doesn't require use of curried closures, but just closures within parallel in general.

          Andrew Bayer added a comment -

          Yet another of the JENKINS-26481 symptoms...

          Andrew Bayer added a comment - Yet another of the JENKINS-26481 symptoms...

          Jesse Glick added a comment -

          Not obviously a duplicate.

          Jesse Glick added a comment - Not obviously a duplicate.

          Andrew Bayer added a comment -

          This works in current (i.e., 2.39) workflow-cps - added a test at https://github.com/jenkinsci/workflow-cps-plugin/pull/160 to verify.

          Andrew Bayer added a comment - This works in current (i.e., 2.39) workflow-cps - added a test at https://github.com/jenkinsci/workflow-cps-plugin/pull/160 to verify.

          Code changed in jenkins
          User: Andrew Bayer
          Path:
          src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java
          http://jenkins-ci.org/commit/workflow-cps-plugin/37e3fdde8a0ee5470924ff09ba3957ec421d29f5
          Log:
          JENKINS-38052 Test verifying that JENKINS-38052 is fixed.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowDefinition2Test.java http://jenkins-ci.org/commit/workflow-cps-plugin/37e3fdde8a0ee5470924ff09ba3957ec421d29f5 Log: JENKINS-38052 Test verifying that JENKINS-38052 is fixed.

            abayer Andrew Bayer
            fortuna Ben Fortuna
            Votes:
            6 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: