JenkinsPipelineUnit icon indicating copy to clipboard operation
JenkinsPipelineUnit copied to clipboard

MissingMethodException calling other groovy file as method

Open Willem1987 opened this issue 4 years ago • 2 comments

From a.groovy i try to call b.grooy as b("firstVar","secondVar")

import helper.SomeClass

def call(String firstVar, String secondVar) {
}

This syntax works in actual jenkins pipeline and is documented on https://www.jenkins.io/doc/book/pipeline/shared-libraries/#defining-custom-steps

In this case it throws an exception: groovy.lang.MissingMethodException: No signature of method: a.b() is applicable for argument types: ( java.lang.String, java.lang.String) values: [firstVar, secondVar]

(I modified the names and classes)

Willem1987 avatar Oct 01 '20 14:10 Willem1987

The actual @Library is in the script in the jenkins job. From there it calls a().

Willem1987 avatar Oct 01 '20 14:10 Willem1987

I could workaround by loading the script and adding an allowed method, but id like to see this work without

Willem1987 avatar Oct 14 '20 19:10 Willem1987