Jenkins构建完成后,在电子邮件正文中嵌入HTML页面

时间:2017-08-24 00:21:09

标签: html jenkins

我有一个Jenkins自动化测试工作,可以创建一些html页面和资源,以显示测试结果。显示测试结果的主要html测试结果页面引用了一些其他本地生成的文件和来自谷歌的图像。我是否可以在Jenkins作业发送的电子邮件正文中嵌入并显示主html页面。如果在浏览器中查看html页面,它应该像通常那样工作,包括引用其他生成的资源以显示测试结果。来自主html测试结果页面的示例生成HTML如下所示。

<html><head><title>Expando Framework Test Execution Report - BLEG Consumer</title><script src='res/tablefilter_all_min.js' type='text/javascript'></script><script src='res/jquery.min.js' type='text/javascript'></script><script src='res/script.js' type='text/javascript'></script><link rel='stylesheet' type='text/css' href='res/style.css' /><script type='text/javascript'>init();</script></head><body><h1 style='text-align:center; color:#971D31;'>Test Execution Report</h1><table border='1' style='font-family:tahoma; font-weight:bold; font-size:8pt; color:#4c4c4c' align='center' cellpadding='5' cellspacing='1'> <tbody>   <tr>        <td colspan='2' style='text-align:center; font-size: 12pt'>BLEG Consumer - Automation Execution Summary</td>    </tr>   <tr>        <td colspan='2' style='text-align:center'><img src='https://chart.googleapis.com/chart?chs=350x100&chd=t:4,0,0,0&cht=p3&chl=Pass-4|Fail-0|NoRun-0|NotCompleted-0&chco=00FF00|FF0000|483D8B|FF8C00' /></td>  </tr>   <tr>        <td colspan='2' />  </tr>   <tr>        <td width='50%'>START TIME</td>         <td width='50%'>2017-08-23 04:04:42 PM</td>     </tr>   <tr>        <td>END TIME</td>       <td>2017-08-23 04:05:16 PM</td>     </tr>   <tr>        <td>DURATION</td>       <td>00:00:34</td>   </tr>   <tr>        <td colspan='2' />  </tr>   <tr>        <td>TOTAL TESTCASES</td>        <td>4</td>  </tr>   <tr style='color:green'>        <td>PASSED</td>         <td>4</td>  </tr>   <tr style='color:green'>        <td>PASS %</td>         <td>100.00</td>     </tr>   <tr style='color:red'>      <td>FAILED</td>         <td>0</td>  </tr>   <tr style='color:red'>      <td>FAIL%</td>      <td>0.00</td>   </tr>   <tr style='color:darkslateblue'>        <td>NORUN</td>      <td>0</td>  </tr>   <tr style='color:darkslateblue'>        <td>NORUN %</td>        <td>0.00</td>   </tr>   <tr style='color:darkorange'>       <td>NOTCOMPLETED</td>       <td>0</td>  </tr>   <tr style='color:darkorange'>       <td>NOTCOMPLETED %</td>         <td>0.00</td>   </tr> </tbody> </table> <!--   Host : AN00621276.eis.equifax.com   Host IP : 172.17.193.47   User : kxi6   --><br /><br /><!--<div style='width:100; bottom:10; right:10; position:fixed; color:green; font-family:Arial; font-size:10;'><marquee>&copy; 2016 Expando&trade; Framework by Shalvin Abraham</marquee></div>--><table id='report' border='1' style='width:100%'><thead><th>Project</th><th>Testcase ID</th><th>Status</th><th>Comment</th><th>Execution Time</th><th>Requests</th><th>Responses</th><th>Query Results</th></thead><tbody>
<tr><td>BLEGCommercial</td><td>BLEG_COMMERCIAL_SUBMIT_1</td><td><font color='green'>PASS</font></td><td style='text-align:left'><div style='text-align:center'>All Assertions are <font color='green'>PASS</font></span></td><td>2017-08-23<br style='mso-data-placement:same-cell;' />16:04:43</td><td><a target='_blank' href='BLEGCommercial/Request_BLEGCommercial_BLEG_COMMERCIAL_SUBMIT_1_S1_20170823.160443.407.xml'> click here </a></td><td><a target='_blank' href='BLEGCommercial/Response_BLEGCommercial_BLEG_COMMERCIAL_SUBMIT_1_S1_20170823.160443.407.xml'> click here </a></td><td><a target='_blank' href='BLEGCommercial/QueryResult_BLEGCommercial_BLEG_COMMERCIAL_SUBMIT_1_S2_20170823.160443.407.xml'> click here </a></td></tr>
<tr><td>BLEGCommercial</td><td>BLEG_COMMERCIAL_SUBMIT_2</td><td><font color='green'>PASS</font></td><td style='text-align:left'><div style='text-align:center'>All Assertions are <font color='green'>PASS</font></span></td><td>2017-08-23<br style='mso-data-placement:same-cell;' />16:04:50</td><td><a target='_blank' href='BLEGCommercial/Request_BLEGCommercial_BLEG_COMMERCIAL_SUBMIT_2_S1_20170823.160450.436.xml'> click here </a></td><td><a target='_blank' href='BLEGCommercial/Response_BLEGCommercial_BLEG_COMMERCIAL_SUBMIT_2_S1_20170823.160450.436.xml'> click here </a></td><td><a target='_blank' href='BLEGCommercial/QueryResult_BLEGCommercial_BLEG_COMMERCIAL_SUBMIT_2_S2_20170823.160450.436.xml'> click here </a></td></tr>
<tr><td>BLEGConsumer</td><td>BLEG_CONSUMER_SUBMIT_1</td><td><font color='green'>PASS</font></td><td style='text-align:left'><div style='text-align:center'>All Assertions are <font color='green'>PASS</font></span></td><td>2017-08-23<br style='mso-data-placement:same-cell;' />16:04:57</td><td><a target='_blank' href='BLEGConsumer/Request_BLEGConsumer_BLEG_CONSUMER_SUBMIT_1_S1_20170823.160457.166.xml'> click here </a></td><td><a target='_blank' href='BLEGConsumer/Response_BLEGConsumer_BLEG_CONSUMER_SUBMIT_1_S1_20170823.160457.166.xml'> click here </a></td><td><a target='_blank' href='BLEGConsumer/QueryResult_BLEGConsumer_BLEG_CONSUMER_SUBMIT_1_S2_20170823.160457.166.xml'> click here </a></td></tr>
<tr><td>BLEGConsumer</td><td>BLEG_CONSUMER_SUBMIT_2</td><td><font color='green'>PASS</font></td><td style='text-align:left'><div style='text-align:center'>All Assertions are <font color='green'>PASS</font></span></td><td>2017-08-23<br style='mso-data-placement:same-cell;' />16:05:10</td><td><a target='_blank' href='BLEGConsumer/Request_BLEGConsumer_BLEG_CONSUMER_SUBMIT_2_S1_20170823.160510.225.xml'> click here </a></td><td><a target='_blank' href='BLEGConsumer/Response_BLEGConsumer_BLEG_CONSUMER_SUBMIT_2_S1_20170823.160510.225.xml'> click here </a></td><td><a target='_blank' href='BLEGConsumer/QueryResult_BLEGConsumer_BLEG_CONSUMER_SUBMIT_2_S2_20170823.160510.225.xml'> click here </a></td></tr>
</tbody></table><script type='text/javascript'>var tf = setFilterGrid('report', getTableProps()); last();</script><div id='last'/></body></html>

2 个答案:

答案 0 :(得分:0)

使用Email-ext plugin发送电子邮件通知。

它在3个方面提供更多控制:触发器,内容,收件人

对于您的查询,它支持发送包含HTML内容的电子邮件。有关更多信息,请查看插件的文档。

答案 1 :(得分:0)

我想出了如何使用电子邮件正文中的FILE变量嵌入HTML。

$ {FILE,path =&#34; html文件路径&#34;}