简体   繁体   English

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

[英]Embedding HTML page in Email Body After Jenkins Build Completes

I have a Jenkins automated testing job that creates some html pages and resources in order to display the test results. 我有一个Jenkins自动化测试工作,该工作创建一些html页面和资源以显示测试结果。 The main html test results page that displays the test results references some other locally generated files and an image from google. 显示测试结果的html测试结果主页面引用了其他一些本地生成的文件和google的图像。 Is it possible for me to embed and display the main html page in the body of an email sent by the Jenkins job. 我是否可以在Jenkins工作发送的电子邮件正文中嵌入并显示主要的html页面。 The html page should work as it normally does if it is being viewed in a browser, including referencing the other generated resources in order to show the test results. 如果在浏览器中查看html页面,则该页面应正常运行,包括引用其他生成的资源以显示测试结果。 Sample generated HTML from the main html test results page is shown below. 从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>

Use Email-ext plugin to send emails notifications. 使用Email-ext插件发送电子邮件通知。

It gives more control in 3 areas: Triggers, Content, Recipients 它在3个区域提供了更多控制权:触发器,内容,收件人

For your query, it supports sending emails with HTML content. 对于您的查询,它支持发送包含HTML内容的电子邮件。 For further more info please go through the documentation of the plugin. 有关更多信息,请浏览插件的文档。

I figured out how to embed HTML using the FILE variable in the body of the email. 我想出了如何使用电子邮件正文中的FILE变量嵌入HTML。

${FILE,path="path to html file"} $ {FILE,path =“ html文件路径”}

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

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