Email Notifications based on If-Then Statements

Bryn Thompson July 27, 2012

Is there an option within JIRA 4.2.4 to configure email notifications with if-then statements in addition to a specific event?

For example,

event = issue assigned

'if (reporter = john) and (assignee = joe) then notify jane'

2 answers

0 votes
Renjith Pillai
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.
July 28, 2012

You seem to be on OnDemand and I am afraid that such customizations are not supported there. Otherwise Jamie's script plugin could probably let you achieve your requirement.

0 votes
Igor Loskutov
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.
July 27, 2012

You have to override standart Jira notification system by custom issue listener with injected or dinamically obtained (ComponentAccessor.getMailQueue()) component MailQueue.

With this component you can add MailQueueItem objects in standart mail queue as standart notifications did.

it works like that :

final Email email = createEmail(); //create email object in your code here
        AbstractMailQueueItem item = new AbstractMailQueueItem(email.getSubject()) {

            private final Logger log = Logger.getLogger(AttachmentusListener.class);

            @Override
            public void send() throws MailException
            {
                incrementSendCount();
                SMTPMailServer smtpMailServer = MailFactory.getServerManager().getDefaultSMTPMailServer();
                if (!MailFactory.isSendingDisabled())
                {
                    if (mailThreader != null) mailThreader.threadEmail(email);
                    smtpMailServer.send(email);
                    if (mailThreader != null) mailThreader.storeSentEmail(email);
                }
            }
        };
        mailQueue.addItem(item);

And you have to manually fill VelocityManager context for generating email body. Here you can use default template path but it is tricky to mimic default notifications velocity context and I recommend use custom email templates.

Suggest an answer

Log in or Sign up to answer