Jenkins发送邮件

<div id="content\_views" class="markdown\_views prism-atom-one-dark"> <!-- flowchart 箭头图标 勿删 --> <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"> <path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path> </svg> <h3><a name="t0"></a><a id="Jenkins\_0" target="\_blank"></a>简介:总结怎么使用Jenkins执行自动化测试后发送测试报告邮件</h3> <h1><a name="t1"></a><a id="\_1" target="\_blank"></a>一、系统设置</h1> <h3><a name="t2"></a><a id="1JenkinsEmail\_Extension\_Plugin\_2" target="\_blank"></a>1、在Jenkins安装Email Extension Plugin插件,如下图:</h3> <p><img src="https://img-blog.csdn.net/20170914084619820?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZ2FsZW4yMDE2/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述"></p> <h3><a name="t3"></a><a id="2Extended\_Email\_Notification\_5" target="\_blank"></a>2、设置Extended E-mail Notification</h3> <p>(1)进入“系统管理”-“系统设置”,对Extended E-mail Notification进行配置,主要点开“高级”才能设置smtp,具体参考下图:<br> <img src="https://img-blog.csdn.net/20170914090431219?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZ2FsZW4yMDE2/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述"></p> <p>注意:上图中的Password不是qq密码,而是在QQ邮箱申请开通IMAP/SMTP服务后收到的密码。开通IMAP/SMTP服务可参考我的另一篇博客:<a href="http://blog.csdn.net/galen2016/article/details/73350606" rel="nofollow" target="\_blank">http://blog.csdn.net/galen2016/article/details/73350606</a></p> <p>(2)还是在“系统管理”-“系统设置”页面,系统管理员地址要设置成和发送邮件的地址一致,不然发送邮件会失败<br> <img src="https://img-blog.csdnimg.cn/20181203181056122.png" alt="在这里插入图片描述"></p> <h3><a name="t4"></a><a id="3\_15" target="\_blank"></a>3、设置邮件通知</h3> <p>还是在系统管理-系统设置里面设置,内容和Extended E-mail Notification差不多,具体如下图:<br> <img src="https://img-blog.csdn.net/20170914093849046?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZ2FsZW4yMDE2/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述"></p> <h3><a name="t5"></a><a id="4Jenkins\_19" target="\_blank"></a>4、Jenkins任务的配置</h3> <p>a、在进入任务的配置页面,然后在构建后操作模块增加构建后的操作“Editable Email Notification”,如图:<br> <img src="https://img-blog.csdn.net/20170914091818057?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZ2FsZW4yMDE2/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述"></p> <p>b、我的Editable Email Notification配置如下:<br> <img src="https://img-blog.csdn.net/20170914092539522?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZ2FsZW4yMDE2/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述"></p> <p>c、注意:还要在高级里设置邮件的触发条件,如下:<br> <img src="https://img-blog.csdn.net/20170914092811823?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZ2FsZW4yMDE2/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述"></p> <p>d、配置格式参考:</p> <hr>(本邮件是程序自动下发,请勿回复!)<br><hr> <p>项目名称: $PROJECT\_NAME<br></p><hr><p></p> <p>Jenkins地址: <a href="http://localhost:8080/jenkins" rel="nofollow" target="\_blank">http://localhost:8080/jenkins</a><br></p><hr><p></p> <p>构建编号: $BUILD\_NUMBER<br></p><hr><p></p> <p>构建状态: $BUILD\_STATUS<br></p><hr><p></p> <p>触发原因: ${CAUSE}<br></p><hr><p></p> <p>构建日志地址: <a href="${BUILD\_URL}console" rel="nofollow" target="\_blank">${BUILD\_URL}console</a><br></p><hr><p></p> <p>构建地址: <a href="$BUILD\_URL" rel="nofollow" target="\_blank">$BUILD\_URL</a><br></p><hr><p></p> <p>变更集: ${JELLY\_SCRIPT,template=“html”}<br></p><hr><br> e、我的邮件内容如下,可参考<p></p> <pre class="prettyprint"><code class="has-numbering" onclick="mdcp.signin(event)">&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;${ENV, var="JOB\_NAME"}-第${BUILD\_NUMBER}次构建日志&lt;/title&gt; &lt;/head&gt; <body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4" offset="0"> <h3>以下是Jenkins自动发送的邮件,请勿回复!</h3> <div> <table width="95%" cellpadding="0" cellspacing="0" style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif"> <tr> <th><br /> <h2>构建信息</h2> </th> </tr> <tr> <td> <ul> <li>项目名称 : ${PROJECT\_NAME}</li><br /> <li>美化的测试报告 : <a href="${PROJECT\_URL}TestReport">${PROJECT\_URL}TestReport</a></li><br /> <li>触发原因: ${CAUSE}</li><br /> <li>项目 Url : <a href="${PROJECT\_URL}">${PROJECT\_URL}</a></li><br /> </ul> </td> </tr> </table> </div> <div> <table> <tr> <th><br /> <h2>测试报告</h2> </th> </tr>
1 &lt;tr&gt; 2 &lt;td&gt; 3 &lt;div&gt;${FILE ,path="C:/Users/lingshu/.jenkins/workspace/BaiduTest/target/surefire-reports/emailable-report.html"}&lt;/div&gt; 4 &lt;/td&gt; 5 &lt;/tr&gt; 6 7&lt;/table&gt; 8&lt;/div&gt;
</body> </html> <div class="hljs-button signin" data-title="登录后复制"></div></code><ul class="pre-numbering" style=""><li style="color: rgb(153, 153, 153);">1</li><li style="color: rgb(153, 153, 153);">2</li><li style="color: rgb(153, 153, 153);">3</li><li style="color: rgb(153, 153, 153);">4</li><li style="color: rgb(153, 153, 153);">5</li><li style="color: rgb(153, 153, 153);">6</li><li style="color: rgb(153, 153, 153);">7</li><li style="color: rgb(153, 153, 153);">8</li><li style="color: rgb(153, 153, 153);">9</li><li style="color: rgb(153, 153, 153);">10</li><li style="color: rgb(153, 153, 153);">11</li><li style="color: rgb(153, 153, 153);">12</li><li style="color: rgb(153, 153, 153);">13</li><li style="color: rgb(153, 153, 153);">14</li><li style="color: rgb(153, 153, 153);">15</li><li style="color: rgb(153, 153, 153);">16</li><li style="color: rgb(153, 153, 153);">17</li><li style="color: rgb(153, 153, 153);">18</li><li style="color: rgb(153, 153, 153);">19</li><li style="color: rgb(153, 153, 153);">20</li><li style="color: rgb(153, 153, 153);">21</li><li style="color: rgb(153, 153, 153);">22</li><li style="color: rgb(153, 153, 153);">23</li><li style="color: rgb(153, 153, 153);">24</li><li style="color: rgb(153, 153, 153);">25</li><li style="color: rgb(153, 153, 153);">26</li><li style="color: rgb(153, 153, 153);">27</li><li style="color: rgb(153, 153, 153);">28</li><li style="color: rgb(153, 153, 153);">29</li><li style="color: rgb(153, 153, 153);">30</li><li style="color: rgb(153, 153, 153);">31</li><li style="color: rgb(153, 153, 153);">32</li><li style="color: rgb(153, 153, 153);">33</li><li style="color: rgb(153, 153, 153);">34</li><li style="color: rgb(153, 153, 153);">35</li><li style="color: rgb(153, 153, 153);">36</li><li style="color: rgb(153, 153, 153);">37</li><li style="color: rgb(153, 153, 153);">38</li><li style="color: rgb(153, 153, 153);">39</li><li style="color: rgb(153, 153, 153);">40</li><li style="color: rgb(153, 153, 153);">41</li><li style="color: rgb(153, 153, 153);">42</li><li style="color: rgb(153, 153, 153);">43</li><li style="color: rgb(153, 153, 153);">44</li><li style="color: rgb(153, 153, 153);">45</li><li style="color: rgb(153, 153, 153);">46</li><li style="color: rgb(153, 153, 153);">47</li><li style="color: rgb(153, 153, 153);">48</li><li style="color: rgb(153, 153, 153);">49</li></ul></pre> <p>注意这行代码:</p><div>${FILE ,path=“C:/Users/kingdee/.jenkins/workspace/AutoTestDemo/target/surefire-reports/emailable-report.html”}</div><br> 作用是引入了testng生成的测试报告,然后在邮件的html里显示出来。<p></p> <h3><a name="t6"></a><a id="5\_103" target="\_blank"></a>5、构建完成后发送的邮件如下:</h3> <p><img src="https://img-blog.csdn.net/20170914093931763?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZ2FsZW4yMDE2/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述"></p>
      </div>
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

java反射, 不看你可别后悔

<divid"content\_views"class"markdown\_views"<!flowchart箭头图标勿删<svgxmlns"http://www.w3.org/2000/svg"style"display:none;"<pathstrokelinecap"round"d"M5,00,

AndroidStudio封装SDK的那些事

<divclass"markdown\_views"<!flowchart箭头图标勿删<svgxmlns"http://www.w3.org/2000/svg"style"display:none;"<pathstrokelinecap"round"d"M5,00,2.55,5z"id"raphael

Native memory allocation (mmap) failed to map xxx bytes for committing reserved memory

<divid"content\_views"class"markdown\_views"<!flowchart箭头图标勿删<svgxmlns"http://www.w3.org/2000/svg"style"display:none;"<pathstrokelinecap"round"d"M5,00,