Technical work, should be praised and then see, form a habitCopy the code

Jenkins uses the tutorial related series catalog


After completion of jenkin-based continuous integration deployment, task construction is completed and test results need to be notified to relevant personnel. This blog introduces how to configure email notification in Jenkins…

First, install the mail plug-in

It is recommended that you install a special email plugin for Jenkins since Jenkins’ email function is weak, but the following section will also introduce how to configure Jenkins’ email function.

You can install the Email Extension Plugin through system management → Management plug-in → Optional plug-in:

Since I have installed the plug-in, it is displayed here under the installed directory. Those who have not installed the plug-in can search the search box in the upper right corner and install it online. After installing it, restart Jenkins.

Second, system Settings

Email configuration through System Management → System Settings:

1. Set Jenkins address and administrator email address

 

2. Set the sender information

PS: The email address of the sender must be the same as the email address of the system administrator (of course, you can also set a special sender email, but it does not affect the use, according to the specific situation can be set)

The default recipient email can be separated by a comma.

 

3. Configure the email content template

Attachment: Mailbox Default Content:

<! DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>${ENV, Var ="JOB_NAME"}- ${BUILD_NUMBER} next 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> <br/> Dear colleagues, Here is ${PROJECT_NAME} project build information < / br > < td > < font color = "# CC0000" > build results - ${BUILD_STATUS} < / font > < / td > < / tr > < tr > < td > < br / > < b > < font color = "# 0 b610b" > 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: ${PROJECT_NAME}</li> <li> build number: ${BUILD_NUMBER} <a href="${BUILD_URL}console">${BUILD_URL}console</a></li> <li> < a href = "${BUILD_URL}" > ${BUILD_URL} < / a > < / li > < li > working directory: < a href = "${PROJECT_URL} ws" > ${PROJECT_URL} ws < / a > < / li > < li > Url of the project: < a href = "${PROJECT_URL}" > ${PROJECT_URL} < / a > < / li > < / ul > < h4 > < font color = "# 0 b610b" > failure cases < / font > < / h4 > < hr size = "2" $FAILED_TESTS width = "100%" / > < br / > < h4 > < font color = "# 0 b610b" > recently submitted (# $SVN_REVISION) < / font > < / h4 > < hr size = "2" width = "100%" / > < ul > ${CHANGES_SINCE_LAST_SUCCESS, reverse = true, the format = "% c", changesFormat = "< li > % d % % [a] m < / li >"} < / ul > submit detailed: <a href="${PROJECT_URL}changes">${PROJECT_URL}changes</a><br/> </td> </tr> </table> </body> </html>Copy the code

4. Set the email trigger mechanism

After completing the steps above, click Apply and save.

 

5. Configure Jenkins’ built-in email function

The configuration content is as follows, which is the same as the Email Extension Plugin. You can test whether the configuration can send the Email successfully by checking the test configuration by sending test Email button, as shown below:

After completing the system Settings above, click Save.

 

Iii. Project configuration

After the system setup is complete, you also need to configure the mail for the project you want to build.

1. Go to the project configuration page

Enter the interface of the new project and click the configuration button to enter the system configuration page:

 

2. Configure the operation module after construction

After entering the system configuration page, click the post-build operation option at the top, and the configuration content is as follows:

Enter the post-build operation module, and you will see the following content. The specific configuration information is marked in the figure:

Connected graph:

The email content can be configured by default. The email content type can be selected based on your own configuration. The recipient list can be configured by default in the previous system Settings.

 

Build trigger mail tests

The following picture shows the test email I received. The email content can be customized through the system Settings. You can refer to the template above or customize it.

 

The above content, namely Jenkins configuration automatic mail sending method, is for reference only…