Following this section of jenkins documentation, I’ve defined a global var in:
my-shared-library/vars/unLabel.groovy
The library is loaded implicitly and the code is:
def call(String labelName, String tfsPath) {
echo "Hello, ${labelName} ${tfsPath}"
}
Next I created a simple pipeline with two parameter FOO and BAR and the script is:
label 'my-agent'
unLabel ${params.FOO}, ${params.BAR}
I got this exception:
hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: org.jenkinsci.plugins.workflow.cps.UninstantiatedDescribableWithInterpolation.unLabel() is applicable for argument types: (org.codehaus.groovy.runtime.GStringImpl, org.codehaus.groovy.runtime.GStringImpl) values: [test1, test2]
Even if I call:
unLabel "test1", "test2"
or
unLabel("test1","test2")
it doesn’t work.
I’ve made a syntax error and I got an exception that shows that the variable is defined:
java.lang.NoSuchMethodError: No such DSL method '$' found among steps [....] or globals [..., env, params, pipeline, scm, unLabel]
So what is wrong here, can someone help me, please?