-->

Email-Ext objects in groovy script as file

2019-09-10 02:36发布

问题:

My question is kind of a follow up of this: How to place Email-Ext groovy script on the jenkins file system

Here is my situation: I have a groovy script which constructs the email which will be send. This works fine as long as I have the script directly written (the code) in:

Pre-send Script


If I take this script, place it in the Jenkins filesystem(...jenkins\email-templates) as: email-presend.groovy and I try to call it with:

  <presendScript>${SCRIPT, script="email-presend"}</presendScript>

I get the error message, that I can't access the message object:

Script1.groovy: 1: expecting EOF, found 'or' @ line 1, column 17. Error in script or template: groovy.lang.MissingPropertyException: No such property: msg for class: Script1

Code on the line:

  msg.addHeader("X-Priority", "1 (Highest)"); 
  msg.addHeader("Importance", "High"); 

Am I missing something obvious, since I can't find any code snippet which did this? I want to use the javax.mail.Message msg which is available if the code is directly in jenkins.

回答1:

Unfortunately it seems like it's not possible according to this post: Email-ext comment

Too bad :(