Hello,

I'm developing a shared library for us across several business units. We 
want to have 1 repo that all BU's can use, but also want to separate 
functionality by business unit. Additionally, we want users to consume the 
latest non-breaking changes of the library. I'm experimenting with a name 
spacing approach. This is some example code:

// var/businessUnitA.groovy

def propertyMissing(String name) {
    return this.class.classLoader.("businessUnitA.v1.$name", true, 
false).newInstance()
}


// src/businessUnitA/v1/Notify.groovy
def sendSlackMessage(arg1, arg2, arg3) {
   // actual logic to send the slack message
}

// Jenkinsfile
businessUnitA.Notify.sendSlackMessage('a', 'b', 'c')

This approach allows us to think of the shared library more like a 
versioned API than a package that might have multiple long-lived major 
versions.

With this background, the problem I'm having is accessing the pipeline 
global variables like `env` in businessUnitA's `missingProperty` function. 
When I try to access `env` in `missingProperty`, it leads to infinite 
loops. I've also tried looking at this.getProperty('binding)  but the 
binding doesn't appear to have those global variables attached. I even 
tried checking out the class loaders to see if there was an existing 
instance I could access. Is there any way I could get at those global 
variables in the `missingProperty` function?


Thanks!

-- 
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/ea778156-2a5e-4903-801d-a0c13f9c598f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to