jenkinsci / jenkinsci/workflow-aggregator-plugin
[JENKINS-37994] pipeline groovy files loaded with default values equal to a function don't run node steps
- Dominant language
- No language data
- Stars
- 225
- Forks
- 125
- PR merge metrics
- No merged PRs in 30d
Description
In groovy, it's legal to have a default parameter value be the result of another function. See works-in-groovy.txt attachment.
In using pipeline, I call load another groovy file (which does a return this at the end). If the default value is the result of another function in the file, any node-context steps then will not run in the loaded file. If I pass a parameter, so the default isn't called, then everything works as expected.
It's also possible that this has something to do with loading the groovy files from the checkout rather than the original SCM scripts dir?
If this isn't expected to work, then an error should be raised rather than failing silently, I think.
In the attachments, test.groovy is the SCM script, and other.groovy is the loaded file.
---
Originally reported by
kmueller, imported from: pipeline groovy files loaded with default values equal to a function don't run node steps
jglick
Raw content of original issue
In groovy, it's legal to have a default parameter value be the result of another function. See works-in-groovy.txt attachment.
In using pipeline, I call load another groovy file (which does a return this at the end). If the default value is the result of another function in the file, any node-context steps then will not run in the loaded file. If I pass a parameter, so the default isn't called, then everything works as expected.
It's also possible that this has something to do with loading the groovy files from the checkout rather than the original SCM scripts dir?
If this isn't expected to work, then an error should be raised rather than failing silently, I think.
In the attachments, test.groovy is the SCM script, and other.groovy is the loaded file.
- environment:
JDK 1.7, jenkins 2.15, pipeline 2.3, pipeline SCM 2.2
3 attachments
- [other.groovy](https://issues.jenkins.io/secure/attachment/33834/other.groovy)
- [test.groovy](https://issues.jenkins.io/secure/attachment/33835/test.groovy)
- [works-in-groovy.txt](https://issues.jenkins.io/secure/attachment/33836/works-in-groovy.txt)
Contributor guide
Research direction
Start by comparing the attached test.groovy and other.groovy files, using works-in-groovy.txt to confirm the valid Groovy behavior. Reproduce the loaded-file case with the listed Jenkins and Pipeline versions, then trace why the node-context steps are skipped when the default function value is used. Done means the behavior is corrected or a clear error is raised.
Written by the indexing model from the issue text.
Assessment
- Domain
- ci-cd
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100