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?
Community moderators have prevented the ability to post new answers.
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; }
For jira cloud? How?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Cloud? It's a server solution.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could sent emails to custom destinations using Raley Email Notifications add-on.
This article explains how to achieve it
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank's, I'll think over your idea.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.