-
Notifications
You must be signed in to change notification settings - Fork 200
Description
At least some closures are executed only once inside of Groovy CPS DSL scripts managed by the workflow plugin.
Steps to reproduce:
1. Create a new workflow with the following script:
node {
[1, 2, 3].each
println "abc".replaceAll(/[a-z]/)
{ it.toUpperCase() } }
2. Build the workflow
Actual output:
Started by user anonymous
Running: Allocate node : Start
Running on master in /var/lib/jenkins/jobs/testflow/workspace
Running: Allocate node : Body : Start
Running: Print Message
1
Running: Print Message
A
Running: Allocate node : Body : End
Running: Allocate node : End
Running: End of Workflow
Finished: SUCCESS
Expected output:
Started by user anonymous
Running: Allocate node : Start
Running on master in /var/lib/jenkins/jobs/testflow/workspace
Running: Allocate node : Body : Start
Running: Print Message
1
Running: Print Message
2
Running: Print Message
3
Running: Print Message
ABC
Running: Allocate node : Body : End
Running: Allocate node : End
Running: End of Workflow
Finished: SUCCESS
Originally reported by dtschan, imported from: Mishandling of binary methods accepting Closure
- assignee:
jglick
- status: Resolved
- priority: Critical
- component(s): workflow-cps-plugin
- label(s): groovy, kohsuke-plane-project, pipeline-hangs
- resolution: Fixed
- resolved: 2017-05-30T23:06:35+00:00
- votes: 108
- watchers: 137
- imported: 2025-12-07
Raw content of original issue
At least some closures are executed only once inside of Groovy CPS DSL scripts managed by the workflow plugin.
Steps to reproduce: 1. Create a new workflow with the following script: node { [1, 2, 3].each
{ println it }println "abc".replaceAll(/[a-z]/)
{ it.toUpperCase() }} 2. Build the workflow
Actual output: Started by user anonymous Running: Allocate node : Start Running on master in /var/lib/jenkins/jobs/testflow/workspace Running: Allocate node : Body : Start Running: Print Message 1 Running: Print Message A Running: Allocate node : Body : End Running: Allocate node : End Running: End of Workflow Finished: SUCCESS
Expected output: Started by user anonymous Running: Allocate node : Start Running on master in /var/lib/jenkins/jobs/testflow/workspace Running: Allocate node : Body : Start Running: Print Message 1 Running: Print Message 2 Running: Print Message 3 Running: Print Message ABC Running: Allocate node : Body : End Running: Allocate node : End Running: End of Workflow Finished: SUCCESS
- environment:
Jenkins LTS 1.580.2 and workflow-plugin 1.1. Both are the latest versions at the time of this writing. Tested on RHEL 6 with OpenJDK 1.7 and Fedora 21 with OpenJDK 1.8.