• 【Linux】【jenkins】自动化运维五 整合邮件提醒


    1.安装插件 Email Extension Template Plugin

    安装教程参考:https://www.cnblogs.com/jxd283465/p/11542680.html

    2.系统设置管理员邮箱及邮件模板等

    在系统设置中找到“Jenkins Location”,配置管理员邮箱,即发信邮箱

    在系统设置中找到“Extended E-mail Notification”

     

     标题:

    构建通知:$PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!

    邮件模板:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>${ENV, var="JOB_NAME"}-第${BUILD_NUMBER}次构建日志</title>
    </head>
     
    <body leftmargin="8" marginwidth="0" topmargin="8" marginheight="4"
        offset="0">
        <table width="95%" cellpadding="0" cellspacing="0"
            style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">
            <tr>
                <td>(本邮件是程序自动下发的,请勿回复!)</td>
            </tr>
            <tr>
                <td><h2>
                        <font color="#0000FF">构建结果 - ${BUILD_STATUS}</font>
                    </h2></td>
            </tr>
            <tr>
                <td><br />
                <b><font color="#0B610B">构建信息</font></b>
                <hr size="2" width="100%" align="center" /></td>
            </tr>
            <tr>
                <td>
                    <ul>
                        <li>项目名称 : ${PROJECT_NAME}</li>
                        <li>构建编号 : 第${BUILD_NUMBER}次构建</li>
                        <li>构建人: ${GIT_BRANCH}</li>
                        <li>触发原因: ${CAUSE}</li>
                        <li>构建日志: <a href="${BUILD_URL}console">${BUILD_URL}console</a></li>
                        <li>构建  Url : <a href="${BUILD_URL}">${BUILD_URL}</a></li>
                        <li>工作目录 : <a href="${PROJECT_URL}ws">${PROJECT_URL}ws</a></li>
                        <li>项目  Url : <a href="${PROJECT_URL}">${PROJECT_URL}</a></li>
                        <li>代码审查: <a href="http://192.168.8.100:9002/dashboard?id=${PROJECT_NAME}">http://192.168.8.100:9002/dashboard?id=${PROJECT_NAME}</a></li>
                    </ul>
                </td>
            </tr>
            <tr>
                <td><b><font color="#0B610B">Changes Since Last
                            Successful Build:</font></b>
                <hr size="2" width="100%" align="center" /></td>
            </tr>
            <tr>
                <td>
                    <ul>
                        <li>历史变更记录 : <a href="${PROJECT_URL}changes">${PROJECT_URL}changes</a></li>
                    </ul> ${CHANGES_SINCE_LAST_SUCCESS,reverse=true, format="Changes for Build #%n:<br />%c<br />",showPaths=true,changesFormat="<pre>[%a]<br />%m</pre>",pathFormat="    %p"}
                </td>
            </tr>
            <tr>
                <td><b>Failed Test Results</b>
                <hr size="2" width="100%" align="center" /></td>
            </tr>
            <tr>
                <td><pre
                        style="font-size: 11pt; font-family: Tahoma, Arial, Helvetica, sans-serif">$FAILED_TESTS</pre>
                    <br /></td>
            </tr>
            <tr>
                <td><b><font color="#0B610B">构建日志 (最后 100行):</font></b>
                <hr size="2" width="100%" align="center" /></td>
            </tr>
            <!-- <tr>
                <td>Test Logs (if test has ran): <a
                    href="${PROJECT_URL}ws/TestResult/archive_logs/Log-Build-${BUILD_NUMBER}.zip">${PROJECT_URL}/ws/TestResult/archive_logs/Log-Build-${BUILD_NUMBER}.zip</a>
                    <br />
                <br />
                </td>
            </tr> -->
            <tr>
                <td><textarea cols="80" rows="30" readonly="readonly"
                        style="font-family: Courier New">${BUILD_LOG, maxLines=100}</textarea>
                </td>
            </tr>
        </table>
    </body>
    </html>

    Jenkins项目配置:

    构建后操作选择--Editable Email Notification

    点击“ Advanced Settings ”设置邮件发送tigger

     

     发送成功!

     

  • 相关阅读:
    MySQL视图和存储过程
    MySQL数据操作
    Pair RDD编程
    HDFS组成架构和读写数据流程
    RDD编程
    MySQL数据查询和函数
    数据库学习(二)
    玩爆你的手机联系人--T9搜索(一)
    POJ3259 Wormholes 【Bellmanford推断是否存在负回路】
    Java 小技巧和在Java避免NullPonintException的最佳方法(翻译)
  • 原文地址:https://www.cnblogs.com/jxd283465/p/11548580.html
Copyright © 2020-2023  润新知