Hello!

I've been having issues with declaring and setting variables within our 
/var/globals.groovy file.  I've followed the cps-global-libs suggestions 
<https://github.com/jenkinsci/workflow-plugin/blob/master/cps-global-lib/README.md#defining-global-variables>
 
and I can execute functions just fine but once it hits a function with a 
reference to a variable... 

groovy.lang.MissingPropertyException: No such property: beginJobEmailBody for 
class: groovy.lang.Binding
        at groovy.lang.Binding.getVariable(Binding.java:62)
        at 
org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:185)
        at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241)
        at 
org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238)
        at 
com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:23)
        at 
com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:17)
        at 
globals.beginBuildNotificationTestEmail(/path/to/workflowLibs/vars/globals.groovy:130)
        at WorkflowScript.run(WorkflowScript:23)
        at ___cps.transform___(Native Method)
        at 
com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:62)


I'm wondering how to declare these properly within the globals.groovy 
script.  Here are some examples of what I've tried:

beginJobEmailBody = "The ${env.JOB_NAME} job has begin on"
def beginJobEmailBody = "The ${env.JOB_NAME} job has begin on"
GString this.beginJobEmailBody = "The ${env.JOB_NAME} job has begin on";

I've also alternated between using the `this` reference to the variables to 
no avail:
...
/**
*  Sends an email to the team to notify of a build has begun
*/
def beginBuildNotificationTestEmail(paramMap) {
   mail body: "${this.beginJobEmailBody} " + paramMap.STAGE + " " + paramMap
.ENVIRONMENT,
 subject: "${this.beginJobEmailSubject}" ,
 to: "${this.emailDevOpsTeam}"
}


return this;

^ as an aside, I have the 'return this;' from when I was loading the script 
previously as a Closure object. Could this cause the issue as well?

-- 
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/2eb7f550-05b6-4270-acbe-c4e25f6c3eb5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to