Email configuration in Jenkins

Please read the following blog to install Jenkins in Windows - Jenkins Installation for Windows

We need to install below plugin for Email from install page of Jenkins - 'Email Extension Plugin'

After installation restart Jenkins and we need to first configure default Email settings.

Default Email Setting:

From Home page, go to Manage Jenkins.

Then click on Configure System.
Fill the details for Extended E-mail Notification:
  • SMTP Server: Check with your team or admin or use gmail (smtp.gmail.com)
  • Click on Advance and then fill
  • SMTP port: Check with your team or admin or use gmail (465)
  • Default Receipients - Your receipents Email ID
  • Reply To List - Your Email ID
  • Default Subject - $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS!
  • Default Content -  $PROJECT_NAME - Build # $BUILD_NUMBER - $BUILD_STATUS:
Check console output at $BUILD_URL to view the results.

After this you can Test Email by using E-mail Notification

Provide same details as above and check 'Test configuration by sending test e-mail'

Build Email notification:

Go to your project for which you want to send Email.

Go to Configure and then Post-build Actions.

Click on button - Add post-build action

select E-mail Notification.

Fill in the details.

Customized Email for every build run:

Go to your project for which you want to send Email.

Go to Configure and then Post-build Actions.

Click on button - Add post-build action

select 'Editable E-mail Notification'

Fill the below details

Java Heap Dumps

As name suggest, Heap dumps are only for java processes.

Commands to take heap dumps:

  • jmap -dump:live,format=b,file=heap.process_name.prof <PID>
  • jmap -dump:live,format=b,file=/home/Dumps/heap.process_name.prof <PID> 

Thread Analysis:

For analysis, we can use Java VisualVM and Eclipse Memory Analyzer

Heap Dump Parameter:

-Xms          set initial Java heap size in m,g or M,G (and not MB or GB)
-Xmx          set maximum Java heap size in m,g or M,G (and not MB or GB)

Garbage Collection:
In Java, there is object life cycle as below:

  • Object creation
  • Object in use
  • Object destruction

We need to clean object to release memory else we will have heap memory reaching 100%. Garbage collection is a way in Java which happens automatically and below are the available algorithm:


  • Mark and sweep:


  • Concurrent mark sweep (CMS) garbage collection:

To use CMS GC, use below JVM argument:
-XX:+UseConcMarkSweepGC


  • Serial garbage collection:

To use Serial GC, use below JVM argument:
-XX:+UseSerialGC


  • Parallel garbage collection:

To use parallel GC, use below JVM argument:
-XX:+UseParallelGC


  • G1 garbage collection:

If you want to use in Java 7 or Java 8 machines, use JVM argument as below:
-XX:+UseG1GC

Thread Dump

Thread dumps are only for java processes.

Commands to take thread dump:

  • jstack -l  <pid> > threaddump.txt
  • kill -3 <pid>
  • jcmd <pid> Thread.print > <file-path>

Thread Analysis:

Thread dumps should be taken multiple times to get exact issue and one dump is not sufficient and may mislead the investigation. We should atleast take 3-5 thread dumps at an interval of 10 secs.30 sec or 1 minutes as per the performance issue.

To analyse, take the thread dumps and upload the files in site - fastThread Java Thread Dump Analyzer

Thread Status:

  • NEW: The thread is created but has not been processed yet.
  • RUNNABLE: The thread is occupying the CPU and processing a task. (It may be in WAITING status due to the OS's resource distribution.)
  • BLOCKED: The thread is waiting for a different thread to release its lock in order to get the monitor lock.
  • WAITING: The thread is waiting by using a wait, join or park method.
  • TIMED_WAITING: The thread is waiting by using a sleep, wait, join or park method. (The difference from WAITING is that the maximum waiting time is specified by the method parameter, and WAITING can be relieved by time as well as external changes.)