-
Type:
Bug
-
Resolution: Not A Defect
-
Priority:
Minor
-
Component/s: pipeline
-
None
-
Environment:Jenkins LTS 2.46.3
Pipeline v2.5
Ā
In the Jenkins docs it indicates that you can define methods within a class in a shared library and that those methods have direct access to the built in Jenkins pipeline steps. This does not appear to be correct. Here's my example code copied nearly verbatim from the docs:Ā
//tmp_shared/vars/acme.groovy class acme implements Serializable { private String name def setName(value) { name = value } def getName() { name } def caution(message) { echo "Hello, ${name}! CAUTION: ${message}" } }
//pipeline script @Library('tmp_shared') _ acme.name = 'Alice' echo acme.name acme.caution 'The queen is angry!'
The errorĀ produced is
hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: acme.echo() is applicable for argument types: (org.codehaus.groovy.runtime.GStringImpl)
Based on my understanding of how the classes are defined, this may be expected behavior since theĀ acme class doesn't derive from the cps dsl base class and thus doesn't support the correct binding environment.
If this behavior is expected then this example should be removed or updated to something that works correctly to avoid confusion. If this behavior is not expected then there is likely a bug in the Jenkins pipeline plugin and this should probably be fixed.
Ā
- relates to
-
JENKINS-41359 Global methods in pipeline shared-library fails when invoked
-
- Resolved
-
- links to