Custom email templates in Jira from plugin

Parashar Joshi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2017

Hi All,

I was referring http://www.j-tricks.com/tutorials/sending-mails-from-jira-plugins
and would like to know if there is any way we can do this email template generation programmatically without having to manually place the 3 files for Html, Text and Subject.

This is because we need this functionality from a plugin and may not have the flexibility to update the jira instance manually.

Any pointers and  help is appraciated.
Thanks in advance.

-Parashar

2 answers

1 accepted

0 votes
Answer accepted
Parashar Joshi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 17, 2017

Implemented the following solution.

1. Created a new event from plugin on plugin enabling/upload.
2. Created a listener module to listen to events and send emails for the specific event created in #1
3. Included the custom email VM templates in the plugin

The listener module or class references this vm template from the plugin and generates the emails that need to be sent for the new event.
The event is dispatched from the code line explicitly.
The velocity is referenced and HTML is created with VelocityManager class object of JIra using the method getEncodedBody().

Saravana Kumar June 26, 2019

Hi @Parashar Joshi, can you provide code for adding template in plugin. i am struggling to add my customize template to inside plugin and don't know how to call it from web work action class

Thanks in advance,

1 vote
Andy Brook
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2017

When you say programatically, you run that 'program' when exactly?

JEMH (we are the vendor) could help with standard Issue Event notifications or Workflow Post Function Scenario, where content can be defined through custom TemplateSets (the subject + text and html).  It also enables authorized users to send mail from the JIRA issue screen through Ad hoc notifications, again, with template driven content.  All template content in JEMH is modified through the UI, no filesystem changes are needed.

See markteplaces for other mail related addons.

Parashar Joshi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2017

Hi Andy,

Thank you for the response and details.

We are working on a plugin which needs to send out email notification on a specific events.
So we have to create a few events in Jira and also create templates for these events.

The plan is to run the creation of these template and get setup correctly when the plugin is installed (using the LifecycleAware methods).

Please see https://community.atlassian.com/t5/JIRA-questions/Create-an-event-in-Jira-from-plugin/qaq-p/627051 for this plugin that i am working on.

I would want to include all configuration inside the plugin (somehow) so that the user does not have to do any configuration like placing the file in this case to 3 different locations. It should be transparent to the user.

Thanks,
Parashar

Andy Brook
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2017

So whats the question?  It sounds like you have a developmen roadmap, so have at it!

Parashar Joshi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2017

Oops, Sorry!
The questions are

1. How can the files be placed into these 3 locations from the plugin without user having to do it?
Or 
How to refer and use the templates from the plugin bundle  where the vm's are in the plugin package?
2. How to programmatically update template mapping from the plugin to refer and use these templates?

Thanks.

Andy Brook
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2017

re: 1, you probably don't want to try.  Trying to write to JIRA folders may give you headaches (permsisions at a minimum, possibility at all given a WAR deployment). Perhaps you make use of JIRA_HOME as a folder owned by the addon.  You have to start doing an awful lot more coding.  This is effectively where JEMH Event Listener comes in.

re: 2, thats your homework, there is a limit to how much dev guidance can be given.

Good luck!

Parashar Joshi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2017

Thank you :)
Appreciate your time, inputs and pointers.

-Parashar

Suggest an answer

Log in or Sign up to answer