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

Map collectEntries closure not behaving correctly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Duplicate
    • Component/s: pipeline
    • Labels:
      None
    • Environment:
      Jenkins 1.6.11
    • Similar Issues:

      Description

      The collectEntries method on Groovy Maps returns an ArrayList instead of a Map, failing its basic function contract. Unknown if this is specific to the workflow plugin or a general issue with Groovy in Jenkins.

      1-line test case from Map.collectEntries documentation:
      assert [a:1, b:2].collectEntries

      { key, value -> [value, key] }

      == [1:'a', 2:'b']

      This may be related to https://issues.jenkins-ci.org/browse/JENKINS-26481 and may be indicative of a general mishandling of Groovy contexts.

        Attachments

          Issue Links

            Activity

            Hide
            jglick Jesse Glick added a comment -

            Probably unrelated to JENKINS-26481.

            Show
            jglick Jesse Glick added a comment - Probably unrelated to JENKINS-26481 .
            Hide
            abayer Andrew Bayer added a comment -

            fwiw, verified that this fails in Workflow normally, but works in Jenkins /script console and in Workflow with @NonCPS.

            Show
            abayer Andrew Bayer added a comment - fwiw, verified that this fails in Workflow normally, but works in Jenkins /script console and in Workflow with @NonCPS .
            Hide
            jglick Jesse Glick added a comment -

            Actually I suspect this is the same as JENKINS-26481: DefaultGroovyMethods.collectEntries is called, but the return value from the first iteration is returned as the value of collectEntries, rather than being passed back into that method for further processing. This kind of bizarre return type is characteristic of JENKINS-26481.

            Show
            jglick Jesse Glick added a comment - Actually I suspect this is the same as JENKINS-26481 : DefaultGroovyMethods.collectEntries is called, but the return value from the first iteration is returned as the value of collectEntries , rather than being passed back into that method for further processing. This kind of bizarre return type is characteristic of JENKINS-26481 .

              People

              Assignee:
              jglick Jesse Glick
              Reporter:
              sumdumgai A C
              Votes:
              3 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: