A jenkins mail template, based on Groovy, capable of querying GitHub in order to obtain tickets URLs of a given build changelog.
This mail template is based on the Email-Ext plugin and uses jenkins Groovy API to obtain information about commits on the Git changelog. Other extremely useful plugin for using along with this template is the Managed Script Plugin, used to make it easy to insert this template into a project Jenkinsfile.
In order to install this template, use the Managed Script Plugin to insert this template into your Jenkins as a Extended Email Publisher Groovy Template.
First of all, using the plugin, create a managed file of type Extended Email Publisher Groovy Template with id jenkins-github-changelog. This file must contain the content of the jenkins-github-changelog.groovy script, existing in this repository.
In your Jenkinsfile, in order to obtain the resolved content of the script, reference the managed script such it is indicated on the example bellow:
def content = '${SCRIPT, template="managed:jenkins-github-changelog"}'
emailext (
to: '[email protected]',
from: '[email protected]',
replyTo: '[email protected]',
subject: "Git changelog!!!",
body: content,
attachLog: false,
mimeType: 'text/html',
)
Don't forget to change the reference baseUrl variable on the template in order to indicate your GitHub/GitHub Entreprise base url:
<!-- CHANGE ME! -->
def baseUrl="https://github.mycompany.com"