I only looked at the pipeline cps-global-lib feature after reading your
e-mail. It is some pretty advanced stuff. :)
I am not a groovy expert, but I will try to explain to the best of my
understanding and hopefully it will lead you on the right path.
When you have a Jenkinsfile or some arbitrary myscript.groovy which is
evaluated by the pipeline plugin, at runtime a class is dynamically
generated called WorkflowScript. If your script throws an exception
which is not caught, you will see a stacktrace line like:
at WorkflowScript.run(WorkflowScript:4)
that gives you a hint that the error occurred on line 4 of your script.
I believe the problem you are hitting with respect to global variables
Under the covers, your pipeline script is being converted into
a Java class. As per the stackoverflow recommendation,
you should prefix your "global variables" with @Field.
So you would do something like this in your globals.groovy file:
// vars/globals.groovy
import groovy.transform.Field
@Field
String beginJobEmailBody = "The ${env.JOB_NAME} has begun"
@Field
String emailDevOpsTeam = "f...@foo.foo"
def beginBuildNotificationTestEmail() {
//mail body: "${this.beginJobEmailBody} " + paramMap.STAGE + " " + paramMap.ENVIRONMENT,
//subject: "${this.beginJobEmailSubject}" ,
//to: "${this.emailDevOpsTeam}"
echo "beginJobEmailBody: ${beginJobEmailBody}"
echo "emailDevOpsTeam: ${emailDevOpsTeam}"
}
and this in your Jenkinsfile
node {
globals.beginBuildNotificationTestEmail()
}
I'm new to groovy, so if there is a better way to do it, let me know.
However, this example does work.
--
Craig