This plugin allows you to configure every aspect of email notifications. You can customize when an email is sent, who should receive it, and what the email says.
Additional recipes for email-ext can be found here.
This plugin extends Jenkins built in email notification functionality by giving you more control. It provides customization of 3 areas.
Before using email-ext on a project, you must configure some global settings. Go to Jenkins System configuration page. Manage Jenkins -> Configure System
The section titled Extended E-mail Notification is where you can configure global email-ext properties. The properties here should match the settings for your smtp mail server. This section is set up to mirror Jenkins own email
For a project to use the email-ext plugin, you need to enable it in the project configuration page. Select the checkbox labeled "Editable Email Notification" in the "Post-build Actions" section.
There are three fields that you can edit when the plugin is enabled.
To see the advanced configuration for the plugin, first click on Override Global setting checkbox, then click the "Advanced" button. This section allows you to specify recipients for each type of email trigger as well as a pre-send script that can be used to modify the email just prior to sending.
The pre-send script is a feature which allows you to write a script that can modify the MimeMessage object prior to sending. This would allow adding custom headers, modifying the body, etc. Predefined variables include:
By default, the only trigger configured is the "Failure" trigger. To add more triggers, select one from the dropdown, and it will be added to the list. Once you have added a trigger, you have several options. If you click "?" (question mark) next to a trigger, it will tell you what conditions must be met for it to send an email.
You can use Trigger Scripts in groovy to define before of after the build if the email must be send or not.
There are four objects added to the model for the script to use to interact with the build.
The last line in the script should resolve to a boolean true or false
The email-ext plugin uses tokens to allow dynamic data to be inserted into recipient list, email subject line or body. A token is a string that starts with a $ (dollar sign) and is terminated by whitespace. When an email is triggered, any tokens in the subject or content fields will be replaced dynamically by the actual value that it represents. Also, the "value" of a token can contain other tokens, that will themselves be replaced by actual content. For instance, the $DEFAULT_SUBJECT token is replaced by the text (and other tokens) that is in the Default Subject field from the global configuration page. Similarly, the $PROJECT_DEFAULT_SUBJECT token will be replaced by the value of the Default Subject field from the project configuration page.
The email-ext plugin sets the email content fields with default values when you enable it for your project. The Default Subject and Default Content fields on the project config page default to $DEFAULT_SUBJECT and $DEFAULT_CONTENT (respectively), so that it will automatically use the global configuration. Similarly, the per-trigger content fields default to $PROJECT_DEFAULT_SUBJECT and $PROJECT_DEFAULT_CONTENT, so that they will automatically use the project's configuration. Since the value of a token can contain other tokens, this provides different points of configuration that can allow you to quickly make changes at the broadest level (all projects), the narrowest level (individual email), and in between (individual project).
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
As of version 2.22, email-ext supports tokens provided by the token-macro plugin. You can see the available token-macro token below the email-ext tokens when you click the "?" (question mark) associated with the Content Token Reference at the bottom of the email-ext section on the project configuration screen.
New to version 2.9 is the ability to use Jelly scripts. Jelly scripts are powerful in that you can hook into the Jenkins API itself to get any information you want or need. There are two Jelly scripts packaged with the plugin and it is possible to write your own too.
There are two default Jelly scripts available out of the box; one is designed for HTML emails and the other is design for text emails. See the screenshots to the right for what these templates look like. You can specify which script you want by using the template argument. The usage for each script is the following:
You can also write your own Jelly scripts. The Jelly scripts are particularly powerful since they provide a hook into the Jenkins API including hudson.model.AbstractBuild and hudson.model.AbstractProject. For example on how to do this, take a look at the existing html and text scripts.
Using custom Jelly scripts (those not packaged with email-ext) requires the cooperation of your Hudson administrator. The steps are relatively simple:
Jelly script tips:
New to version 2.15 is the ability to use Groovy scripts. Scripts are powerful in that you can hook into the Jenkins API itself to get any information you want or need. There are two scripts with corresponding templates packaged with the plugin and it is possible to write your own too.
There are two default scripts and templates available out of the box; one is designed for HTML emails and the other is design for text emails. You can specify which script you want by using the script _argument, you can also just leave the default script and specify a different template file using the _template argument. Further, you can also include an init script that does some initialization using the init argument. The usage for each script is the following:
You can also write your own scripts and templates. The scripts are particularly powerful since they provide a hook into the Jenkins API including hudson.model.AbstractBuild and hudson.model.AbstractProject. For example on how to do this, take a look at the existing html and text scripts.
Using custom scripts (those not packaged with email-ext) requires the cooperation of your Jenkins administrator. The steps are relatively simple:
These are some useful examples for doing various things with the email-ext groovy templates.
New to version 2.15 is the ability to add attachments using the Ant pattern matching syntax used in many places in Jenkins. You can set a maximum total attachment size in the global configuration page, or it will be unlimited.
jive-formatter.groovy contains methods for easy and convenient formatting of emails being sent from Jenkins to Jive. It should be called from the Pre-send Script area.
Also, it doesn't seem like Jive supports text with multiple formats, so only call one formatting method per block of text.
Either formatLine or formatText can and should be called on every line of text that will be sent to the Jive system prior to calling formatting methods like color or size. Please test on your own instances of Jive and add functionality as you find it!
The following lines should be added to the Pre-send Script area prior to attempting to invoke any functions.
Make sure you have installed Maven 3 (why?) and JDK 6.0 or later. Make also sure you have properly configured your ~/.m2/settings.xml as explained in the Plugin Tutorial. This is needed to build properly any Jenkins plugin.
How to check out the source and build:
This version requires Jenkins 1.396 or newer.
This version requires Hudson 1.356 or newer.
Skip to end of metadata Go to start of metadata