jenkins build summarize the relevant issues

! # / bin / the bash
Find / home / autoTest / report -mmin -5 -type CP -exec {F} / opt / Tomcat / the webapps / examples / Report / ATS / Python \; # Copy / home / autoTest / report path recent files created within the next 5 minutes to opt / tomcat / webapps / examples / report ats under / / / python path \; not the province
cd / opt / tomcat / webapps / examples / report / ats / python

report = 'find / opt / tomcat / webapps / examples / report / ats / python -mmin -1 -type f' # Find / opt / tomcat / webapps / examples / report / ats / last one minute is generated file path python assigned to the variable report

$ {Report} -exec mv -f {} ./report.html \; # Rename the variables report report.html

 

#判断 '"status": "werwr"' 是否在report.html中 
if grep -qE '"status": "werwr"' report.html;then
echo "Build Fail"
exit 1
else
echo "Build Success"
exit 0
fi

 

Two, jenkins mail template to build

 

1, the message header: Construction of notification: [$ {PROJECT_NAME}] build automated tests daily - $ {BUILD_STATUS}!

 

2, mail template content

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>${ENV, var="JOB_NAME"}-第${BUILD_NUMBER}次构建日志</title>
</head>





















<tr> <td colspan="2" align="center"><br />
<tr>
<td>
<b><h2><font color="#0B610B">构建信息</font></h2></b>
<hr size="2" width="100%" align="center" /></td>
</tr>
<tr>
<td>
<ul>
<li>项目名称&nbsp;:&nbsp;${PROJECT_NAME}</li>
<li>构建编号&nbsp;:&nbsp;第${BUILD_NUMBER}次构建</li>
<li>触发原因:&nbsp;${CAUSE}</li>
<li>构建日志:&nbsp;<a href="${BUILD_URL}console">${BUILD_URL}console</a></li>
<li>构建&nbsp;&nbsp;Url&nbsp;:&nbsp;<a href="${BUILD_URL}">${BUILD_URL}</a></li>
<li>工作目录&nbsp;:&nbsp;<a href="${PROJECT_URL}ws">${PROJECT_URL}ws</a></li>
<li>项目&nbsp;&nbsp;Url&nbsp;:&nbsp;<a href="${PROJECT_URL}">${PROJECT_URL}</a></li>
<li>Git&nbsp;&nbsp;&nbsp;&nbsp;Url&nbsp;:&nbsp;<a href="https:XXXXXXXXXXX/focus-dts-auto">https://rep.360taihe.com/focus-dts/focus-dts-auto</a>
</li>
</ul>
</td>
</tr>
<tr>
<td><h2><b><font color="#0B610B">代码变更记录</font></h2></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="&nbsp;&nbsp;&nbsp;&nbsp;%p"}
<br /> </td>
</tr>
<tr>
<td><pre
</tr>
<tr>
<td><h2><b><font color="#0B610B">构建日志(最后100行)</font></h2></b>
<hr size="2" width="100%" align="center" /></td>
</tr>
<tr>
<td><textarea rows="30" readonly="readonly"
style="font-family: Courier New; width: 100%">${BUILD_LOG, maxLines=100}</textarea>
</td>
</tr>
</table>
</body>
</html>

Guess you like

Origin www.cnblogs.com/yanpan/p/10948929.html