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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Mail Handler is not adding email into comment section in an exisinting ticket

We would like to use mail handler for Nagios alerts. We would like to create Jira a ticket whenever an alert receive, if an issue exist with same subject then it should add email into comment. I am trying the following script but it is not adding email into comment, it is only creating tickets whenever I send a test email, even I'm sending the same email. Am I missing something?

import com.atlassian.jira.component.ComponentAccessor 
import com.atlassian.jira.service.util.ServiceUtils
import com.atlassian.jira.service.util.handler.MessageUserProcessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
import com.atlassian.mail.MailUtils

def userManager = ComponentAccessor.getComponent(UserManager)
def projectManager = ComponentAccessor.getProjectManager()
def issueFactory = ComponentAccessor.getIssueFactory()
def messageUserProcessor = ComponentAccessor.getComponent(MessageUserProcessor)
def subject = message.getSubject() as String
def issue = ServiceUtils.findIssueObjectInString(subject)

if (issue) {

ApplicationUser user = userManager.getUserByName("admin")
ApplicationUser reporter = messageUserProcessor.getAuthorFromSender(message) ?: user
def project = projectManager.getProjectObjByKey("ALERT")

def issueObject = issueFactory.getIssue()

issueObject.setDescription(MailUtils.getBody(message)) issueObject.setIssueTypeId(project.issueTypes.find { == "Task" }.id) issueObject.setReporter(reporter)

messageHandlerContext.createIssue(user, issueObject)


Here is the email example

Subject: PROBLEM Service Alert: td-application-01/Service Check: PRT is CRITICAL


***** Nagios  Alert *****

Notification Type: PROBLEM

Service: Service Check: PRT
Host: td-application-01
Address: td-application-01

Date/Time: Thu Jul 30 14:41:59 PST 2020


Thank you

1 answer

Do follow up emails from Nagios have the Jira issue key in the subject? I don't see that anywhere.

No there isn't an issue key. Below is the an example of the follow up email. However I sent the above email multiple time and each time it created a new ticket. If a system is down it keeps sending an alert after every hour till issue get resolved. Once issue gets resolved then it will send the Recovery email.

 For example if the above system is down for 4 hours, it will send 4 "Problem" emails and once it gets resolved then it will send a "Recovery" email. We want the Jira to create only  one ticket for all. The first 4 emails would be the same email with and final one will be a little bit different, as you can see it in the below example. How we can accomplish that? Thank for your help.


Subject: Recovery Service Alert: td-application-01/Service Check: PRT is OK


***** Nagios  Alert *****

Notification Type: Recovery

Service: Service Check: PRT
Host: td-application-01
Address: td-application-01
State: OK

Date/Time: Thu Jul 30 14:41:59 PST 2020

Thank you,

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

Happy New Year and Welcome New Marketplace Partner Program Partners!

Happy New Year! We hope you all had a safe and restful holiday season. 2020 was a unique year full of unforeseen events; however, as we enter the new year of 2021, we’re optimistic for the light at t...

413 views 5 15
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you