Hi,
I have a problem executing closures in my pipeline, since they return early. I could break down the problem to the following minimal example:
class Foo {
Closure<String> cl = { String a ->
return "Say: ${this.bar(a)}"
}
String bar(String a) {
return "Hello ${a}."
}
}
Foo f = new Foo()
String output = f.getCl()("World")
echo(output)The expected output of this code is "Say: Hello World.", which it returns when I execute it locally in native Groovy. However, in a Jenkins pipeline job the code returns "Hello World.".
I assume that the closure directly returns the output of the this.bar(a) method call.
After having already reported a
ticket for this issue, does somebody know more about this issue? Is there a workaround available?
Thanks.