Help with using the scripts int he vars directory of shared libraries

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Help with using the scripts int he vars directory of shared libraries

I'm writing share libraries by following Extending with Shared Libraries, and I have a simple example working.

I now have created a script in the vars directory called debugger.groovy, that has a class definition, like this

class MyDebugger {
def logError(String msg) {
("ERROR", msg)
private def log(String msgType, String msg) {
String m = "$msgType: $msg"

MyDebugger getDebuggerObj() {
return (new MyDebugger)

Now I have a script in my src/com/company directory called Deployer.groovy, and I want to use above MyDebugger like this because I want to use the same MyDebugger object all throughout my script.


class MyDeployer {
def dbgObj = debugger.getDebuggerObj()

def deploy() {
Deployer d = new MyDeployer()

When I run it in my Jenkins pipeline, like this

pipeline {
{ label 'linux-devops' }
('build') {
// This is the Library configured in Jenkins main configuratin page
def deployer = new com.zift.deployment.Deployer()

But I get

infrastructure/src/com/zift/deployment/EcsClusterBuilder.groovy: 9: Apparent variable 'debugger' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes: You attempted to reference a variable in the binding or an instance variable from a static context. You misspelled a classname or statically imported field. Please check the spelling. You attempted to use a method 'debugger' but left out brackets in a place not allowed by the grammar.

 What's a better approach? I still want to keep the degugger.groovy structure, but am flexible on the Deployer.groovy script.


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 [hidden email].
To view this discussion on the web visit
For more options, visit