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

Script runner custom email added as comment

Patrick August 19, 2014

Hello,

I'm using Script Runner plugin with JIRA to send a custom email when an issue is resolved.

The email is sent, but the problem is that the content of this email is added as a comment to the corresponding issue.

Is there any solution to avoid this ?

12 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
Patrick August 21, 2014

Thanks for your answer, I understand now the problem :

When an issue is sent to "issues@mycompany.com", I configured JIRA to create a user for every CC adresses so they can receive email when the issue is resolved. But sometimes, the email adress "issues@mycompany.com" is not the direct recipient of the email, it is put in the CC field. So the user "issues@mycompany.com" is created ...

0 votes
Patrick August 21, 2014

Thanks for your answer, I understand now the problem :

When an issue is sent to "issues@mycompany.com", I configured JIRA to create a user for every CC adresses so they can receive email when the issue is resolved. But sometimes, the email adress "issues@mycompany.com" is not the direct recipient of the email, it is put in the CC field. So the user "issues@mycompany.com" is created ...

0 votes
JamieA
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 21, 2014

Addresses can't watch issues, only users. So it sounds like some user has the the email address "issues@mycompany.com", and if that's the address of the inbox used for incoming email, that's a big problem.

You will end up getting yourself into a never ending of cycle of adding a comment, sending a mail etc etc

0 votes
Patrick August 20, 2014

Well issues are sent to an adress, let's say 'issues@mycompany.com' and this adress is automatically added as a watcher. I didn't do anything for that, and that's the problem.

0 votes
JamieA
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 19, 2014

Why would you add the incoming email address as a watcher? That makes no sense to me.

0 votes
Patrick August 19, 2014

Ok so I managed to achieve something but it's totally ugly : I remove the watcher by adding some code in the body of the email template (I can't figure out why if I place this code in a listener or in a postfunction, it doesn't work)

Here is the code :

def watcherManager = com.atlassian.jira.component.ComponentAccessor.getWatcherManager()
def userManager = com.atlassian.jira.component.ComponentAccessor.getUserManager()
 
def user = userManager.getUser('myUser')
watcherManager.stopWatching(user, issue)

0 votes
Patrick August 19, 2014

Well so I should maybe try to write a script wich remove the inbox email from that watchers list when an issue is created.

0 votes
Patrick August 19, 2014

Yes indeed, I configured a mail handler for incoming mails. The adress of that inbox is automatically added as a watcher of the issue (this is probably a problem). The email I send with the custom listener is sent to the reporter and the watchers.

But I didn't have this problem when I used default email provided by JIRA in the notification scheme.

0 votes
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 19, 2014

HI Patrick,

As Jamie already pointed out, I think you have a mail handler configured for the project to which the "corresponding issue" belongs and the mail address your sending the mail to is the same as the project's mail handler address which results in the comment being added.

0 votes
JamieA
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 19, 2014

Do you have incoming mail configured, and are you sending it to that inbox?

0 votes
Patrick August 19, 2014

Actually I didn't use a postfunction to do that. Im using the 'Send a custom email' listener provided by the plugin.

0 votes
Alexey_Rjeutski__Polontech_
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 19, 2014

As I understood you have a script postfunction? Could you share code that does that logic?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events