当前位置:网站首页>Jenkins continuous integration environment build 8 (configure mailbox server to send build results)
Jenkins continuous integration environment build 8 (configure mailbox server to send build results)
2022-06-30 02:03:00 【Public righteousness】
List of articles
1. install Email Extension plug-in unit

2. Jenkins Set mailbox related parameters
Manage Jenkins -> Configure System
With this option setting 
Before adding an email address , First open the mailbox SMTP function 
Get the authorization code :
LW**N*****GDL**V
Jenkins Local system configuration 
Mailbox parameter settings 
Add credentials 



Configuration testing 
test result 

3. Prepare the email content
Switch commit Branch master
If you switch to... In another branch master.
Write... In the project root directory email.html, And push the files to Gitlab
email.html Content
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>${ENV, var="JOB_NAME"}- The first ${BUILD_NUMBER} Secondary build log </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>( This message was sent automatically by the program , Please do not reply !)</td>
</tr>
<tr>
<td><h2>
<font color="#0000FF"> The build results - ${BUILD_STATUS}</font>
</h2></td>
</tr>
<tr>
<td><br />
<b><font color="#0B610B"> Build information </font></b>
<hr size="2" width="100%" align="center" /></td>
</tr>
<tr>
<td>
<ul>
<li> Project name : ${PROJECT_NAME}</li>
<li> Build number : The first ${BUILD_NUMBER} Time to build </li>
<li> trigger : ${CAUSE}</li>
<li> The build log : <a href="${BUILD_URL}console">${BUILD_URL}console</a></li>
<li> structure Url : <a href="${BUILD_URL}">${BUILD_URL}</a></li>
<li> work do Objective record : <a href="${PROJECT_URL}ws">${PROJECT_URL}ws</a></li>
<li> project Url : <a href="${PROJECT_URL}">${PROJECT_URL}</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> calendar The history of change more remember record : <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"> The build log ( Last 100 That's ok ):</font></b>
<hr size="2" width="100%" align="center" /></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>
Get the help guide for variables 

Mail template submitted to gitlab Of master On the branch 
4. To write Jenkinsfile Send mail after adding build
4.2 Jenkinsfile Content
primary Jenkinsfile
pipeline {
agent any
stages {
stage('pull code') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/${branch}']], extensions: [], userRemoteConfigs: [[credentialsId: '0b127895-eb97-4f8f-b471-1277e5549b54', url: '[email protected]:test-group/web_demo.git']]])
}
}
stage('build project') {
steps {
sh 'mvn clean package'
}
}
stage('deploy item') {
steps {
deploy adapters: [tomcat8(credentialsId: '1cf9c5dd-8e2d-4eb6-8c00-bb60e0f027ca', path: '', url: 'http://192.168.10.40:8080/')], contextPath: null, war: 'target/*.war'
}
}
}
}
After adding the steps related to mailbox notification Jenkinsfile
pipeline {
agent any
stages {
stage('pull code') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/${branch}']], extensions: [], userRemoteConfigs: [[credentialsId: '0b127895-eb97-4f8f-b471-1277e5549b54', url: '[email protected]:test-group/web_demo.git']]])
}
}
stage('build project') {
steps {
sh 'mvn clean package'
}
}
stage('deploy item') {
steps {
deploy adapters: [tomcat8(credentialsId: '1cf9c5dd-8e2d-4eb6-8c00-bb60e0f027ca', path: '', url: 'http://192.168.10.40:8080/')], contextPath: null, war: 'target/*.war'
}
}
}
post {
always {
emailext(
subject: ' Build notifications :${PROJECT_NAME} - Build # ${BUILD_NUMBER} - ${BUILD_STATUS}!',body: '${FILE,path="email.html"}', to: '[email protected]'
)
}
}
}
Pay attention to modifying the email address , Submitted to the Gitlab
4.2 Post Code template generation guide
Click... In the project configuration 《 Pipelining grammar 》



4.3 modify index.jsp And submit to master Branch


4.4 Test build



4.5 Check E-mail

边栏推荐
- 004_ icon
- C language score ranking
- Three questions from the boss
- Matlab 2012a 绘制带箭头的线段
- 012_ switch
- The first technology podcast month will begin soon
- Illustration Google V8 19: asynchronous programming (II): how does V8 implement async/await?
- Restore a 35k-55k Tencent Android Senior Engineer Interview
- C language continues (3n+1) conjecture
- [MySQL 06] backup and restore MySQL database in Linux + docker container environment
猜你喜欢

004_ icon

想转行,但不知道自己要做什么工作比较好?
![[machine learning Q & A] cosine similarity, cosine distance, Euclidean distance and the meaning of distance in machine learning](/img/34/367c66b8d10e896848b102a7f9aa89.png)
[machine learning Q & A] cosine similarity, cosine distance, Euclidean distance and the meaning of distance in machine learning

C语言 我要通过

8 — router

DTW学习(dynamic time warping)——思想、代码实现

Scala基础【入门及安装】
![[MySQL 04] use MySQL workbench 8.0 CE to back up and restore MySQL databases in Linux](/img/e7/fc2925a10ac5fb370dd221c3f4a46a.png)
[MySQL 04] use MySQL workbench 8.0 CE to back up and restore MySQL databases in Linux
![[graph neural network] overview of graph classification learning [2]: graph classification based on graph neural network](/img/5f/b23b64eed7f28ffd92c122b6859e2d.png)
[graph neural network] overview of graph classification learning [2]: graph classification based on graph neural network

What problems can cloud storage architecture solve for Devops?
随机推荐
MySQL monitoring 3
MySQL monitoring 5
C语言 说反话
9 — 正则校验集合
Cookie encryption 15 login encryption
What is idempotency? Detailed explanation of four interface idempotence schemes!
005_ button
js Array. Five convenient applications of from()
[pytorch actual combat] generate confrontation network Gan: generate cartoon character avatars
C language output integer in another format
Method of converting songs from DTS to MP3
DTW学习(dynamic time warping)——思想、代码实现
Varnish foundation overview 1
谁再用Redis过期监听实现关闭订单,立马滚蛋!
Who can use redis expired monitoring to close orders and get out of here!
C语言 数素数
Summary of DOM
Unity2d-- add keys to animation and bind events
【MySQL 06】linux + Docker容器环境中备份和还原MySQL数据库
The first technology podcast month will begin soon