• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • pipeline

      If you have a Java object array (as opposed to a list, as with typical Groovy code) and try to pass it as an argument to a CPS-transformed method, only the first element arrives, rather than an array.

      Workarounds:

      • wrap the array in Arrays.asList before passing it, and treat the argument as a List
      • annotate the method as @NonCPS (assuming it is not calling any steps)

          [JENKINS-32062] Arrays may not be passed directly to methods

          Jesse Glick added a comment -

          Released groovy-cps 1.6; need to wait for it to synch to Central, then try using from workflow-cps and clean up a couple of TODOs (e.g., use new printStackTrace method).

          Jesse Glick added a comment - Released groovy-cps 1.6; need to wait for it to synch to Central, then try using from workflow-cps and clean up a couple of TODOs (e.g., use new printStackTrace method).

          Jesse Glick added a comment -

          OSSRH release did not work. Retried; waiting again.

          Jesse Glick added a comment - OSSRH release did not work. Retried; waiting again.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          CHANGES.md
          cps/pom.xml
          http://jenkins-ci.org/commit/workflow-plugin/4cbff8ccdd6cf1e9f5cd2e7eb87524ef673a143a
          Log:
          [FIXED JENKINS-32062] Integrate groovy-cps 1.6 with several fixes.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: CHANGES.md cps/pom.xml http://jenkins-ci.org/commit/workflow-plugin/4cbff8ccdd6cf1e9f5cd2e7eb87524ef673a143a Log: [FIXED JENKINS-32062] Integrate groovy-cps 1.6 with several fixes.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          CHANGES.md
          cps/pom.xml
          http://jenkins-ci.org/commit/workflow-plugin/97ce55c78e776242adf56d917ed2ee3bd40b46d6
          Log:
          Merge pull request #295 from jglick/groovy-cps-JENKINS-32062

          JENKINS-32062 Integrate groovy-cps 1.6

          Compare: https://github.com/jenkinsci/workflow-plugin/compare/92fe988e8909...97ce55c78e77

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: CHANGES.md cps/pom.xml http://jenkins-ci.org/commit/workflow-plugin/97ce55c78e776242adf56d917ed2ee3bd40b46d6 Log: Merge pull request #295 from jglick/groovy-cps- JENKINS-32062 JENKINS-32062 Integrate groovy-cps 1.6 Compare: https://github.com/jenkinsci/workflow-plugin/compare/92fe988e8909...97ce55c78e77

          Code changed in jenkins
          User: Jesse Glick
          Path:
          cps/pom.xml
          http://jenkins-ci.org/commit/workflow-cps-plugin/9c8d5460a2e507d1c97282e64eb43ec836883354
          Log:
          [FIXED JENKINS-32062] Integrate groovy-cps 1.6 with several fixes.
          Originally-Committed-As: 4cbff8ccdd6cf1e9f5cd2e7eb87524ef673a143a

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: cps/pom.xml http://jenkins-ci.org/commit/workflow-cps-plugin/9c8d5460a2e507d1c97282e64eb43ec836883354 Log: [FIXED JENKINS-32062] Integrate groovy-cps 1.6 with several fixes. Originally-Committed-As: 4cbff8ccdd6cf1e9f5cd2e7eb87524ef673a143a

          Gerard Ryan added a comment -

          I think I might have experienced this same issue just now with pipeline plugin v2.5 and pipeline groovy plugin v2.42. I'm just reporting because looking at the release dates of versions there and the timing of when this issue was closed, seem to indicate that it should have been in releases before the one I'm on. I see in the release notes for pipeline groovy v2.44 it says: "Pick up recent groovy-cps fixes including resolving a quirk with field initialization and CPS transforms", so I'll try again after I can update past that, to see if that fixes it.

          Here's a small reproducer pipeline:

          String[] xs = ["one", "two", "three", "four", "five"]
          
          Closure f = { nums ->
              return nums.collect { num ->
                  return "${num}-${num}"
              }
          }
          
          println f(xs)
          

          This prints [o-o, n-n, e-e] rather than the expected [one-one, two-two, three-three, four-four, five-five]. If I change xs to List<String> then I get the expected result.

          Gerard Ryan added a comment - I think I might have experienced this same issue just now with pipeline plugin v2.5 and pipeline groovy plugin v2.42. I'm just reporting because looking at the release dates of versions there and the timing of when this issue was closed, seem to indicate that it should have been in releases before the one I'm on. I see in the release notes for pipeline groovy v2.44 it says: "Pick up recent groovy-cps fixes including resolving a quirk with field initialization and CPS transforms", so I'll try again after I can update past that, to see if that fixes it. Here's a small reproducer pipeline: String [] xs = [ "one" , "two" , "three" , "four" , "five" ] Closure f = { nums -> return nums.collect { num -> return "${num}-${num}" } } println f(xs) This prints [o-o, n-n, e-e] rather than the expected [one-one, two-two, three-three, four-four, five-five] . If I change xs to List<String> then I get the expected result.

            jglick Jesse Glick
            jglick Jesse Glick
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: