Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to add a custom notification recipient in JIRA?

Mikhail_Kopylov
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.
April 14, 2014

JIRA has a great and fluent notification function.

But I can't find, how to add a custom notification recipient in my plugin?

E. g. I've got an issue with custom field NotifyEmails where some emails are stored.

How to configure JIRA notification scheme to send notifications to emails in this field?

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Mikhail_Kopylov
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.
June 17, 2014

So, JIRA Notification tool can't help with this goal.

Here's my workaround:

1. Implement Job for SAL PluginScheduler: https://developer.atlassian.com/display/DOCS/Scheduling+Events+via+SAL+Tutorial

2. This job will found issues and send the email for each issue.

Here's my code to send a email for issue. Note that this code sends the email immediately.

Email email = new Email( emailToAddress );
        try {
            email = new EmailBuilder( email, "text/html", Locale.ENGLISH ).withSubject( "My subject" )
                    .withBodyFromFile( "templates/email/html/my_template.vm" ) // here can be both a standart template and your custom tempalte
                    .addParameters( getContextParameters() ).renderNow();
            MailServerManager mailServerManager = ComponentAccessor.getMailServerManager();
            SMTPMailServer server = mailServerManager.getDefaultSMTPMailServer();
            if (null == server) {
                throw new RuntimeException( "Can't get default SMTP mail server" );
            }
            server.send( email );
        } catch (MessagingException | MailException e) {
            log.error( "Error while sending email", e );
            return;
        }
private Map<String, Object> getContextParameters( ) {
        Map<String, Object> params = new HashMap<>();
        params.put( "issue", ComponentAccessor.getIssueManager().getIssueObject( "ISSUE-555" ) );
        return params;
    }

Alex Medved _ConfiForms_
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.
November 6, 2015

For jira cloud? How?

Mikhail_Kopylov
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.
November 6, 2015

Cloud? It's a server solution.

Like rishinn likes this
1 vote
Vladimir Horev _Raley_
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.
November 3, 2015

You could sent emails to custom destinations using Raley Email Notifications add-on.

This article explains how to achieve it

 

1 vote
Paresh Gandhi
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.
April 15, 2014

You can write groovy script at the back end which will take out data from custom field NotifyEmail and add those users to watchers of that issue.

I hope this may help you.

Mikhail_Kopylov
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.
April 15, 2014

pareshkumar gandhi, I write a plugin on Java, why do you tell about Groovy?

And to add watchers I need to have users with such emails. But I don't have any.

I need to add a custom recipient email in notification scheme, not in issue.

How to do that?

Paresh Gandhi
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.
April 15, 2014

Sorry, I miss understood the question. I have not done this.

Below colud be the worst solution which came into my mind:

Use java code to login to some exchange accont where it is sending notification email (jira user, test user account may help), find the email and forward that to recepients from custom field value.

Please post your answer if you find anything. Thanks.

Mikhail_Kopylov
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.
April 15, 2014

Thank's, I'll think over your idea.

TAGS
AUG Leaders

Atlassian Community Events