Jenkins管道脚本发送自定义电子邮件

时间:2018-09-02 10:59:19

标签: jenkins groovy jenkins-plugins jenkins-pipeline html-email

我一直在尝试将自己的自定义内容用于Jenkins构建电子邮件。当我尝试根据前一阶段的结果动态更改html的内容时,我陷入了困境。我将html的内容传递给一个变量,如下所示,当我尝试访问其中的哈希列表时,未打印arrays(键和数组的值)的值。

  def content = """\
<html>
<head>
<style>
</style>
</head>
<body>
<table style=" background-color:lightgreen; width:900px;margin:0;">
<tr>
  <th>Build Results :</th>
</tr>
<tr>
<td>project Name : </td>
<td>project URL : </td>
</tr>
<tr>
  <td>Build Number : ${var3} </td>
</tr>
 <tr>
  <td>Buid URL :</td>
</tr>
</table>
<table style=" background-color:lightblue; width:900px;margin:0;">
<tr>
<% stagearray.each { item -> 
def key=item.key;
def value=item.value; %>
<td>${key}</td>
<td>${value}</td> 
<% }  %>
</tr>
this is the sample
<tr><td>This is test line </td></tr>
</table>
</body>
</html>
"""

任何帮助将不胜感激。

0 个答案:

没有答案