As documented in https://jenkins.io/doc/book/pipeline/shared-libraries/, 
I've created the file vars/acme.groovy in a library project checked into 
our SVN.


def setName(value) {
    this.name = value;
}
def getName() {
    return this.name;
}
def caution(message) {
    echo "Hello, ${this.name}! CAUTION: ${message}"
}




My pipeline script in a Jenkins2 pipeline project:
acme.name = 'Alice'
echo acme.name 

acme.caution 'The queen is angry!'




The two first lines, setting and getting the name works fine.
But when I include the last line, calling the "caution" function the script 
fails with


hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No 
signature of method: static Alice.caution() is applicable for argument 
types: (java.lang.String) values: [The queen is angry!]
Possible solutions: caution(java.lang.Object), wait(), 
main([Ljava.lang.String;)
at 
groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1503)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1489)
at 
org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticMetaClassSite.java:53)
at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at 
com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:18)
at WorkflowScript.run(WorkflowScript:8)



If I remove the first 2 lines of the pipeline script, leaving only the 
"acme.caution" call, the error detail is changed to

hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No 
signature of method: static acme.caution() is applicable for argument types: 
(java.lang.String) values: [The queen is angry!]



Jenkins version 2.41
Pipeline plugin 2.4


Any idea what's going on here?  Feels like a bug, or at least wrong doc...?

regards
Tor Christian Solevågseide

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/4ea660e5-672e-404d-b0d3-d8733878221d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to