Email-Ext objects in groovy script as file
My question is a follow up to this: How to host Email-Ext groovy script on jenkins filesystem
Here is my situation: I have a groovy script that creates an email to be sent. This works great if I write the script directly (code) to:
Pre-Submit Script
If I take this script, put it in Jenkins filesystem (... jenkins \ email-templates) as: email-presend.groovy and I am trying to call it with
<presendScript>${SCRIPT, script="email-presend"}</presendScript>
I am getting the error that I cannot access the message object:
Script1.groovy: 1: awaiting EOF, found 'or' @ line 1, column 17. Error in script or template: groovy.lang.MissingPropertyException: No such property: msg for class: Script1
Code on line:
msg.addHeader("X-Priority", "1 (Highest)");
msg.addHeader("Importance", "High");
I'm missing something obvious, since I can't seem to find the piece of code that did this? I want to use javax.mail.Message msg which is available if the code is right in jenkins.
source to share