-
New Feature
-
Resolution: Unresolved
-
Major
-
Shared Groovy Libraries plugin 2.8
Jenkins 2.49
It is not possible to pass Groovy method references as parameters to other methods if the method reference points to a DSL object. The code below demonstrates that the method reference works fine with the "println" method available to all Groovy objects, but fails when the reference points to "steps.echo", where steps is the DSL object available in all Jenkinsfiles.
foo(this.&println) foo(steps.&echo) def foo(arg) { arg.call("hello") }
fails with the following:
[Pipeline] echo hello [Pipeline] End of Pipeline [BFA] Scanning build for known causes... [BFA] No failure causes found [BFA] Done. 0s hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: org.jenkinsci.plugins.workflow.cps.DSL.echo() is applicable for argument types: (java.lang.String) values: [hello]