JIRA generates emails in reaction to events using a templating engine. The templating engine is Apache's Velocity. This is a relatively easy to use templating language that can pull apart java objects in useful ways. The mails are generated inside JIRA by invoking Velocity with a set of objects of relevance to the event.
- To change the columns in your filter subscriptions, you don't need to customize the mail templates. See Customizing your Issue Navigator.
- There's a feature request to improve this at JRA-7266, which you can vote on to improve its chances of being implemented.
- Bear in mind that the next time you upgrade JIRA – or need a new installation for any reason – you will have to manually copy any changes you have made to Velocity templates (as well as JSPs) into the new installation of JIRA. If the Velocity templates and/or JSPs have changed in the newer version, you will have to manually port your customizations into them (as opposed to copying these files directly over from your old JIRA installation to your upgraded one).
Customizations to Velocity templates or other JIRA files are not included in the scope of Atlassian Support.
Email template locations
To customize email content, please follow this procedure.
- Open up your JIRA distribution, and navigate to the following paths:
<jira-application-dir>in your JIRA Installation Directory.
jira/src/etc/java/templates/email/in your extracted JIRA source directory.
- Under this directory there are three directories:
htmlsubdirectory contains the templates used to create emails in html, while the
textdirectory the plain text mail outs. The
subjectdirectory contains the templates used to generate the subject of the emails. The templates are named after the event that will trigger the email.
- Bring the template up in your favorite text editor. Referring to the JIRA template documentation (particularly Velocity Context for Email Templates) and Velocity Users Guide, make the customizations you want.
- Restart JIRA.
For new email templates:
- Create your new
mytemplate.vmfiles in the
subjectdirectories, based on the existing files in those directories
- Add the templates to
atlassian-jira/WEB-INF/classes/email-template-id-mappings.xmlto make them valid choices for when you are adding a new event.
Note that since JIRA 4.1 each new template has to have a corresponding file in the
The Issue object is passed into the
vm templates. Notice some of its implementation in
/includes/summary-topleft.vm. As an example, calling
$issue.getProject() would allow you to determine the project an issue comes from, and even create logic to show different information for emails from different projects.
Deploying Velocity templates without restarting JIRA
In a development instance, you can play with picking up velocity file changes without a restart.
- Remove the comment sign (
Making this change in production will eventually lead to JIRA not serving pages along with the ran out of parsers error in the log file.
See also Adding Custom Fields to Email.