Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
Jenkins ver. 2.89.4, Pipeline: Groovy 2.45
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
- relates to
-
JENKINS-44924 pipeline groovy script - Sort a list with custom comparator or closure not sorting
-
- In Progress
-
So I think this is something similar to JENKINS-44924 - ComposedClosure#call is calling delegate.call, but in a non-CPS context, so the old CpsCallableInvocation fun we used to have with any use of .each and friends is showing up again. I don't yet have a good answer on JENKINS-44924, but once I do, it should be easy enough to handle ComposedClosure with a CPS-specific implementation.