0% found this document useful (0 votes)
20 views

Steps To Set Up Email Notification in Jenkins

The document outlines the steps to configure email notifications in Jenkins including creating an app password in Google, configuring email settings and SMTP server details in Jenkins, testing the configuration, and saving the changes.

Uploaded by

jalebibhai111
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Steps To Set Up Email Notification in Jenkins

The document outlines the steps to configure email notifications in Jenkins including creating an app password in Google, configuring email settings and SMTP server details in Jenkins, testing the configuration, and saving the changes.

Uploaded by

jalebibhai111
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Steps to set up email notification in Jenkins:

1. Create App Password in Google Account:

o Log in to your Google account.


o Navigate to the security settings.
o click on 2 step verification & go at the end
o Look for the option to create an App Password.
o Generate a new App Password and note it down. This will be used for
SMTP authentication in Jenkins.

2. Configure Email Notification in Jenkins:

o Log in to your Jenkins dashboard.


o Go to "Manage Jenkins" from the sidebar.
o Select "Configure System".
o Locate the section for "E-mail Notification" or "Extended E-mail
Notification".

3. SMTP Configuration:

o In the SMTP server field, enter smtp.gmail.com.


o Set the SMTP port to 465.
o Ensure that SSL is checked to enable secure communication.

4. Credentials:

o Under the SMTP Authentication section, select "Use SMTP


Authentication".
o Enter your Google email address in the "User Name" field.
o Use the App Password generated earlier as the "Password".

5. Test Configuration:

o Scroll down to the bottom of the configuration page.


o Click on the "Test configuration by sending test e-mail" button.
o Verify that you receive the test email in your inbox.

6. Save Changes:

o Once the test email is successfully sent and received, click on "Save" to
apply the changes.

7. Sample Scipt

post {

always {

script {

def jobName = env.JOB_NAME

def buildNumber = env.BUILD_NUMBER

def pipelineStatus = currentBuild.result ?: 'UNKNOWN'

def bannerColor = pipelineStatus.toUpperCase() == 'SUCCESS' ? 'green' :


'red'

def body = """<html>

<body>

<div style="border: 4px solid ${bannerColor}; padding:


10px;">

<h2>${jobName} - Build ${buildNumber}</h2>

<div style="background-color: ${bannerColor}; padding:


10px;">

<h3 style="color: white;">Pipeline Status:


${pipelineStatus.toUpperCase()}</h3>

</div>
<p>Check the <a href="${BUILD_URL}">console
output</a>.</p>

</div>

</body>

</html>"""

emailext (

subject: "${jobName} - Build ${buildNumber} -


${pipelineStatus.toUpperCase()}",

body: body,

to: '[email protected]',

from: '[email protected]',

replyTo: '[email protected]',

mimeType: 'text/html',

attachmentsPattern: 'trivy-report.html'

You might also like