It seems that in a pipeline, Groovy closures are returned early if you call a method inside them. The closure then only returns the return value of the called method. I provided a minimal sample to reproduce the bug below.
- Execute the following code in a Jenkins pipeline
- It does not matter if the code is executed in the sandbox or not
- The expected output, as tested with Groovy 2.4.7 locally, is:
- Say: Hello World.
- Jenkins however outputs:
- Hello World.