-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
Ubuntu 16.04.6 LTS
OpenJDK Runtime Environment
java.runtime.version: 1.8.0_181-8u181-b13-2~deb9u1-b13
Jenkins ver. 2.164.1
Groovy plug-in version 2.2
Running Jenkins master inside Docker container
I have a shared library my-lib that contains only one file vars/hello.groovy:
// vars/hello.groovy def call(params) { println "DEBUG A-1" }
I also have the following Jenkins job:
library "my-lib@master" node("master") { writeFile file: "myTest.groovy", text: """ def execute() { println "DEBUG 1" hello() println "DEBUG 2" hello() println "DEBUG 3" } // Boilerplate-coding necessary! Do not delete! return this """ def localtest = load "myTest.groovy" localtest.execute() }
The job worked fine in Jenkins 2.60.3 (Groovy plug-in version 2.0)
// output in Jenkins 2.60.3
DEBUG 1
DEBUG A-1
DEBUG 2
DEBUG A-1
DEBUG 3
However, the same job fails in Jenkins 2.164.1 (Groovy plug-in version 2.2).
// output in Jenkins 2.164.1 DEBUG 1 DEBUG A-1 DEBUG 2 java.lang.NoSuchMethodError: No such DSL method 'call' found among steps
Note that only the second call to hello fails.
There are two workarounds:
- In hello.groovy, simply say def call() and invoke with hello().
- In hello.groovy, leave def call(params) and invoke with hello(null).
Workaround 1. doesn't really work for me since hello has optional input parameters. Workaround 2. doesn't really work for me since I would need to adjust lots of consumers.