Hi there
I'm trying to use the escalation service to notify assignees when they have tickets more than 5 days old. Currently, the JQL/script I am using would send an email for every single ticket found by the JQL.
Is there any way of sending any assignees found by the JQL a single email, with a list of all applicable tickets?
The script I am using is this:
import com.atlassian.mail.Email;
import com.atlassian.mail.server.MailServerManager;
import com.atlassian.mail.server.SMTPMailServer;
import com.atlassian.jira.component.ComponentAccessor;
def subject = "Please review and update aged ticket ${issue.key}"
def body = "Hi ${issue.assignee.displayName} \n\nYou are receiving this email because the issue https://jira.aws.telegraph.co.uk/browse/${issue.key} - ${issue.summary}, is unresolved and more than 5 days old. \n\nPlease review and, where possible, resolve this issue."
def emailAddr = issue.getAssignee().getEmailAddress()
def sendEmail(String emailAddr, String subject, String body) {
SMTPMailServer mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer();
if (mailServer) {
Email email = new Email(emailAddr);
email.setSubject(subject);
email.setBody(body);
mailServer.send(email);
}
sendEmail (emailAddr, subject, body)
Hi Adam,
Assuming that at some point in your code you are getting an array of issues returned by your JQL search, you can construct a multi-line string which would list the links to every issue you find and then use that string in your email body, like so:
String issueLinks = "https://yourjira.com/browse/${issuesFromJql[0].getKey()}"
if (issuesFromJql.size() > 1){
for (int i = 1; i < issuesFromJql.size(); i++){
issueLinks = issueLinks + "${System.lineSeparator()}https://yourjira.com/browse/${issuesFromJql[i].getKey()}"
}
}
String body = """
Hi, here's a list of your issues:
${issueLinks}
"""
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.