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

Create job on JIRA for daily email reminder

Drishti Maharaj May 10, 2022

Hi,

Is it possible to create a custom job on JIRA to send a daily email reminder?

I have looked into adding a post-function once an issue moves to the status but this would just be a once off email reminder. 

We cannot add add-ons to our instance so 3rd party apps do not work and automation on server does not seem to cater for this.

I have this script that could work and run as a daily job based on the JQL query of when those tickets are in the specific status. 

The JQL query is as follows: "project = XXXXXX AND status = "Line Manager Approval"

The only thing is the email to be sent is to different people.
The names of the people who the email is sent to is under a custom field called "Requestors Approving Manager/Executive" on the issues.

This custom field is configured as follows :
User Filtering:
Filtering users by the following:
Project Role: Approvers

How do I edit the below script to include the above information and send the email to the right people?

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 = "Manager Approval for ${issue.key}"
def body = "Hi ${issue.assignee.displayName} \n\nReminder for approval for the following issue: {issue.key} - ${issue.summary}. \n\n"
def emailAddr = issue.getAssignee().getEmailAddress() //this is where I am having trouble configuring for the custom field email address
 
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);
} else {
// Problem getting the mail server from JIRA configuration, log this error
}
}
 
sendEmail (emailAddr, subject, body)

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Sreenivasaraju P
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.
May 10, 2022

Hi @Drishti Maharaj ,

 

Can you provide more details of your requirement. 

 

Regarding sending daily reminder, have you tried to filter subscription ?

 

More details of subscription @ 

https://confluence.atlassian.com/jiracoreserver085/working-with-search-results-981157534.html#Workingwithsearchresults-subscribeSubscribingtoyoursearchresults

Drishti Maharaj May 10, 2022

Hi @Sreenivasaraju P , yes we have tried that but the user who need to receive the email reminders do want that method. 

Hence I am trying to find another solution.

0 votes
Drishti Maharaj May 10, 2022

N/A

TAGS
AUG Leaders

Atlassian Community Events