Situation is simple - 

IN A GLOBAL LIBRARY (OUTSIDE THE SANDBOX):

in src - a.b.c.Utils.groovy

in vars - Defaults.groovy


How do I call Defaults.groovy from within Utils.groovy?

In src:

#!groovy
package a.b.c

public class Utils implements Serializable {
    def script
    public def run() {
         script.echo(Defaults.text)//groovy.lang.MissingPropertyException: No 
such property: Defaults for class: a.b.c.Utils
    }
}

in vars

#!groovy

public class Defaults {
    public static def text = "hello world"
}

in Jenkinsfile:

@Library("ItLoads")
utils = new a.b.c.Utils(this)
...
    utils.run()

so I tried to load the library explicitly

#!groovy
package a.b.c

public class Utils implements Serializable {
    def script
    public def run() {
         println(script.library("ItLoads").Defaults.text)//Only using first 
definition of library pipelineUtilities
//java.lang.IllegalAccessException: Defaults was defined in 
file:///apps/opt/.../vars/Ansible.groovy which was not inside 
file:///apps/opt/.../src/
    }
}

So, Defaults *is* defined somewhere, but I have no idea how to get to it...

*If I try to use Defaults in the Jenkinsfile, it works*


*Help!*

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/9d040a04-919c-4f23-b50d-7e430f0dc69d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to