Isaac Freeman
Isaac Freeman

Reputation: 308

Jenkins/Groovy: How to pass named parameters and closures to the same method?

I have a shared library method with this signature:

call(Map kwargs, String image_name, String version, Closure closure)

And I'm calling it like so:

dockerBuildWith("go-build", "latest", image_context: "build", 
                changesets: ["build/Dockerfile"]) {
  ...
}

But I'm getting this error:

hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: dockerBuildWith.call() is applicable for argument types: (java.util.LinkedHashMap, java.lang.String, java.lang.String, org.jenkinsci.plugins.workflow.cps.CpsClosure2) values: [[image_context:build, changesets:[build/Dockerfile]], go-build, ...]

Possible solutions: call(java.lang.String, java.lang.String, groovy.lang.Closure), wait(), any(), run(), run(), dump()

Upvotes: 1

Views: 1353

Answers (1)

Isaac Freeman
Isaac Freeman

Reputation: 308

I forgot to put def in front of the call() definition.

Upvotes: 0

Related Questions