简体   繁体   English

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

[英]Email-Ext objects in groovy script as file

My question is kind of a follow up of this: How to place Email-Ext groovy script on the jenkins file system 我的问题是这种情况的跟进: 如何将电子邮件扩展Groovy脚本放置在jenkins文件系统上

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: 如果我使用此脚本,请将其放置在Jenkins文件系统(... jenkins \\ email-templates)中, 格式为: email-presend.groovy,然后尝试使用以下命令进行调用:

  <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 Script1.groovy:1:期望EOF,在第1行第17栏找到“或”。脚本或模板中的错误:groovy.lang.MissingPropertyException:无此类属性:类:Script1的msg

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. 我想使用javax.mail.Message消息,如果代码直接在jenkins中可用。

Unfortunately it seems like it's not possible according to this post: Email-ext comment 不幸的是,根据这篇文章看来这是不可能的: Email-ext comment

Too bad :( 太糟糕了 :(

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM