groovy 脚本中的 Email-Ext 对象作为文件

Email-Ext objects in groovy script as file

我的问题是跟进这个问题: How to place Email-Ext groovy script on the jenkins file system

这是我的情况: 我有一个 groovy 脚本,用于构建将要发送的电子邮件。 只要我将脚本(代码)直接写在:

Pre-send Script


如果我使用这个脚本,将它放在 Jenkins 文件系统(...jenkins\email-templates) 中,如下所示:email-presend.groovy 然后我尝试调用它:

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

我收到错误消息,我无法访问消息对象:

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

代码上线:

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

我是否遗漏了一些明显的东西,因为我找不到执行此操作的任何代码片段? 如果代码直接在 jenkins 中,我想使用 javax.mail.Message msg。

不幸的是,根据这个 post,这似乎是不可能的: Email-ext comment

太糟糕了:(