1. Plug-in download

Before configuring Email, we need to download two plug-ins: Email Extension and Email Extension Template. These two plug-ins can help us write, send and format emails

  • inSystem management->Plug-in managementDownload plug-ins from:

2. Configure Email(provided with Jenkins)

2.1 Querying Basic Information

Find the basic information to configure the mailbox, here to QQ mailbox as an example

  1. Enter the setting page of mailbox client through the setting of QQ mailbox on the webpage
  2. Find the basic information of the email

2.2 Jenkins Email notification configuration

  1. In Jenkins:System Management -> System ConfigurationFound at the bottomEmail notificationOpen,senior:
  2. Enter the configuration information as follows:
  3. Note that under the configuration there is a “test configuration by sending test email”, we can check it, fill in the email address, and clickTest configurationLet’s test the email delivery first

2.3 Pit stepping time

  1. If you follow the above method, clickTest configurationThe following error occurs:
javax.mail.AuthenticationFailedException: 535 Login Fail. Please enter your authorization code to login. More information in http://service.mail.qq.com/cgi-bin/help? subtype=1&&id=28&&no=1001256Copy the code

Service.mail.qq.com/cgi-bin/hel…

  1. After modifying the authorization code, you may receive the following error again:
java.net.SocketException: Connection closed by remote host
Copy the code

Jenkins Location
Email address of the system administrator
Email notification
The user name

2.4 Acceptance of Results

After completing the above steps, test again to see that the email was successfully sent

3. Configure Email(Extended Email Notification)

Remember to download the Extended plug-in mentioned at the beginning of this article. Yes, The Jenkins system setup also allows you to customize the template format for sending emails through Extended E-mail Notification

3.1 Configuring Basic Information

The basic information is the same as the preceding information, except that an authorization code needs to be generated again

3.2 Template Format Configuration

Here is mainly to configure the display template format, commonly used formatting parameters are:

- $BUILD_STATUS- Construction result -$PROJECT_NAME- Build script name -$BUILD_NUMBER- Build script number -$JOB_DESCRIPTION- Build project Description -$CAUSE- Script startup cause -$BUILD_URL- SCRIPT build details URLCopy the code

Here choose to display it in HTML format and fill in the template:

<hr/>(Automated build email, no need to reply!)<br/><hr/>Project name: $PROJECT_NAME<br/><br/>Description: $JOB_DESCRIPTION<br/><br/>Run number: $BUILD_NUMBER<br/><br/>Result: $BUILD_STATUS<br/><br/>${CAUSE}<br/><br/>Build log address:<a href="${BUILD_URL}console">${BUILD_URL}console</a><br/><br/>Build address:<a href="$BUILD_URL">$BUILD_URL</a><br/><br/>Details: ${JELLY_SCRIPT, template = "HTML"}<br/>
<hr/>
Copy the code

3.3 Configuring Trigger Conditions

You can also configure the triggering conditions for your messages according to your needs in Default Triggers

In order to prevent the mail bombardment caused by the failure of the build, you can set the mail to be sent only when the first or second build result is failed, and the subsequent failed mail will not be sent

3.4 Acceptance of Results

  1. In the task configuration for the build, select”Editable Email Notification
  2. Configure the mail to be sent toRecipient ListThe email address configured in
  3. After saving, build the project, view the result, and send the email successfully