How to include git changelog in Jenkins emails? How to include git changelog in Jenkins emails? git git

How to include git changelog in Jenkins emails?


I configured my Email-ext plug-in to use the CHANGES Token (official documentation here):

Changes:${CHANGES, showPaths=true, format="%a: %r %p \n--\"%m\"", pathFormat="\n\t- %p"}

That prints the following in my build notifications:

Changes:Username: 123    - Project/Filename1.m    - Project/Filename2.m    -- "My log message"

For HTML messages, I placed the same code within a div and added formatting:

<div style="padding-left: 30px; padding-bottom: 15px;">${CHANGES, showPaths=true, format="<div><b>%a</b>: %r %p </div><div style=\"padding-left:30px;\"> &#8212; &#8220;<em>%m</em>&#8221;</div>", pathFormat="</div><div style=\"padding-left:30px;\">%p"}</div>

Here's a sample screenshot of how it looks in the e-mails sent out by Jenkins now (this particular commit came from Subversion, but it works exactly the same for Git and other version control systems):

Change list for Jenkins


From original documentation:To see a list of all available email tokens and what they display, you can click the "?" (question mark) associated with the Content Token Reference at the bottom of the email-ext section on the project configuration screen.

Here is result:

${CHANGES}Displays the changes since the last build.showDependencies    If true, changes to projects this build depends on are shown. Defaults to falseshowPaths    If true, the paths, modifued by a commit are shown. Defaults to falseformat    For each commit listed, a string containing %X, where %x is one of:    %a        author    %d        date    %m        message    %p        path    %r        revision    Not all revision systems support %d and %r. If specified showPaths argument is ignored. Defaults to "[%a] %m\\n"pathFormat    A string containing %p to indicate how to print paths. Defaults to "\\t%p\\n"


Not in the subject of an email though you can send the change log to the recipient as an attachment in a mail using Git Changelog Plugin as post build action in Jenkins Job. Select Create a file checkbox, give a name to a file (CHANGELOG.md for me), as in below image:

enter image description here

Make sure you have configured Source Code Management as GIT in Jenkins JOB.

Then create Editable Email Notification post build action and copy the name of the git change log file as the value of Attachments, as in below image:

enter image description here