The following function demonstrates the problem:
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].
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.