Email Subject configuration

I need to configure the new version (jira 7.4) to have the generated email notifications include the status of the ticket at each stage:

  • [JIRA] Created: (CTT-xxxx)
  • [JIRA] Assigned: (CTT-xxxx)
  • [JIRA] Resolved: (CTT-xxxx)
  • [JIRA] Reopened: (CTT-xxxx)
  • [JIRA] Closed: (CTT-xxxx)

  Having these statuses in the email subject was very helpful, especially for setting up Outlook email Rules.

1 answer

1 votes
Tarun Sapra Community Champion Jul 31, 2017

You would need to customize the velocity templates. Please see here

https://confluence.atlassian.com/adminjiraserver073/customizing-email-content-861253783.html

Also, in the velocity template you have the issue object thus from issue object you can easily extract the status and put in the subject line of email.

Thanks Tarun for the reply. Could you please be more specific. I just installed jira 7.4 and restore the xml and everything working fine. Able to create tickets and recieving email notifications for every status. I read the above doc in the link you provided before i created this ticket but still no clue. Really Appreciate if you provide steps. I am new to this JIRA and we are using standalone win 2012 server.

 

Thanks

Venkata

Tarun Sapra Community Champion Jul 31, 2017

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.
 Please Note:
To change the columns in your filter subscriptions, you don't need to customize the mail templates.
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
Open up your JIRA distribution, and navigate to the following paths:
The WEB-INF/classes/templates/email/ of the <jira-application-dir> in your JIRA installation directory.
The jira/src/etc/java/templates/email/ in your extracted JIRA source directory.
Under this directory there are three directories: html, text and subject. The html subdirectory contains the templates used to create emails in html, while the text directory the plain text mail outs. The subject directory 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.vm files in the html, text and subject directories, based on the existing files in those directories
Add the templates to atlassian-jira/WEB-INF/classes/email-template-id-mappings.xml to 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 subject directory.


Advanced customization
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.

Tarun Sapra Community Champion Jul 31, 2017

Hi Venkata,

 

The Above documentation explains all that is required. You need to work with someone who has access to the server where JIRA is deployed as you need to modify files present in the "installation directoy" of JIRA on the server. The system information section of jira shows the path to installation directory on the JIRA server.

This is a bit advance configuration thus you need someone with basic linux/windows admin skills and small bit programming as you need to customize the velocity template.

Tarun,

I am the one who installed win 2012 server, installed Jira and make it work and is in production since last week. I have full access the server. My hosting team helped me with SSL/HTTPS. I read somewhere that i need to modify  issuecreated and other VM files from C:\Program Files\Atlassian\JIRA\atlassian-jira\WEB-INF\classes\templates\email\subject folder. But the programming code i have no clue what to add.

Thanks

Venkata

 

Tarun Sapra Community Champion Jul 31, 2017

Hello Venkata,

I would suggest you only modify issueUpdated velocitytemplate as you want to include issue status in the subject line and for issue create event it doesn't matter as at the time of creation of the issue the status is open.  Thus, you can modify the issueUpdated.vm file and since issue object is present thus it's very simple change not much programming experience in the subject you just need to add

$issue.getStatus() in the subject at the right place in the string.

Even when user created the ticket, the subject : simply shows [JIRA] (CTT-xxxx) and not [JIRA] Created: (CTT-xxxx). My previous jira version 3 does show [JIRA] Created: (CTT-xxxx). This thing changed now after  i updaged to 7.4 version. I compared with the old version and couldn't figure out the difference.  I looked into below link and followed it and still no luck.

https://confluence.atlassian.com/jirakb/event-type-name-in-jira-email-subjects-missing-after-upgrade-to-4-4-x-or-above-269979882.html

Tarun Sapra Community Champion Aug 01, 2017

In the old version the velocity templates might have been modified. When you upgrade to the new version you have to manually take the backup of oldvelocity templates and set it for the new version. Customizations are not automatically upgraded while upgrading JIRA.

GM Tarun,

I checked the files and there is no change on the date for any of those files. It's exactly the date and time of the installation on the older version. What i read so far is that prior to version 4 there are no extra changes needed to show Subject:[JIRA] Created: (xxx-xxxx). Starting from jira version 5 we need to modify the VM files to get that.  And i tested copying the old version velocity templates and pasted on newer version and still no luck.

Thanks

Venkata

 

Tarun Sapra Community Champion Aug 01, 2017

Well the answer you have shared has the exact same link which I have shared as the top voted answer. I don't know where the confusion is. As, you just have to edit the template and thats it.

As far as coding is concerned then since your requirement is to append the current workflow status in the subject line thus you would need to add the code line in the subject line.

$issue.getStatus() 

Since you have moved from JIRA version 3.x to 7.x then ofcourse there are changes in the notification template hence you need to do this very simple customization. 

Tested in DEV environment:

Shutdown Jira

added the code on each event

started Jira

Result: No change

Can you paste the issueUpdate.vm file present in the subject subdirectory

also, is your DEV environment sending out notifications? As the change will be noticed in the notifiction and only the changes made in the subject subdirectory's VM files will update the email's subject.

$issue.getStatus()

This is exactly i have in every event file closed/opened/resolved/created/assigned/commented.

 

Yes i did receive notifications on all events with correct status in summary but the subject is not appened witht the status.

 

Did you look into text sub-directory or the subject sub-directory as these files are present in both sub-directories.

Yes these files are present in both directories but i did not change it on text -directory? Do i need to copy these files and paste it on text directory

Changing the "Update.vm" event file in the subject sub-directory should be sufficient to reflect the status in the subject line. If it's not working then problem lies somewhere else.

Another sample snippet in below link

Can i try the below code in issueupdate.vm?

 

If issue.get("status").getName()=="Created"
[Created]: ($issue.key) $issue.summary
 else
If issue.get("status").getName()=="Assigned"
[Assigned]: ($issue.key) $issue.summary
else
If issue.get("status").getName()=="Resolved"
[Resolved]: ($issue.key) $issue.summary
 else
If issue.get("status").getName()=="Closed"
[Closed]: ($issue.key) $issue.summary
 else
If issue.get("status").getName()=="Reopened"
[Reopened]: ($issue.key) $issue.summary
end

Tarun Sapra Community Champion Aug 01, 2017

But this is more easy and straightforward without hardcoding the status in code.

[$issue.status]: ($issue.key) $issue.summary

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Thursday in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

238 views 0 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot