-
Bug
-
Resolution: Unresolved
-
Minor
-
Jenkins 2.198
workflow-cps ("Pipeline: Groovy") 2.74
Debian 9
OpenJDK 11.0.4
The following function demonstrates the problem:
Object func1() { Object m = [:]; m.with { x = 1 }; return m; } assert func1() == [ : ]; // wrong, should be [x:1]
This is supposed run the "x=1" in the context of m. However, func1() returns an empty map.
If func is marked @NonCPS, it returns map [x:1].
@NonCPS Object func2() { Object m = [:]; m.with { x = 1 }; return m; } assert func2() == [ x:1 ];
Running these in a Jenkinsfile. When run in the script console, the @NonCPS is not needed (behaves as expected).
My expectation is that func1 should work without needing a @NonCPS annotation.