I need to trigger an email to the individuals assignees of a project along with their issues count. please provide me the script.
You could create a filter for "assigned to currentUser() and resolution is empty" and then get each of them to subscribe to it.
Thanks for the reply, but i want the data like something below -
Hi (Assignee name),
For the "project", there are (count of issues) assigned to you. Have a look at these issues by clicking on the below link-
"The URL of the issues" .
I want to trigger an email so how to use the filter?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's not hard to write a script that will run JQL and do things with the results, including sending mails out.
I'm not sure how I would write this, as you've not defined when you want to run it (every morning would probably be of most use to the users, without spamming them all day)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic,
Correct probably once in a day , can you please help me out with this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Note - We are using the cloud version of Jira
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well, the basics are http://scriptrunner-docs.connect.adaptavist.com/jiracloud/scheduled-jobs.html but I don't think you can write "email people" scripts in Cloud.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the reply, but how to get the count of issues assigned to each idividual.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Shrikant Maheshwari @Nic Brough -Adaptavist-
Were you able to get the issue count for each assignee from JQL using groovy. I can get the total issue count from the JQL, but i am looking for individual assignee issue count. I am running this as services. Please help.
Regards,
Deepali
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You would need one JQL query per assignee. Or use "assignee = currentUser()"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
package examples.docs
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.mail.Email;
import com.atlassian.mail.server.MailServerManager;
import com.atlassian.mail.server.SMTPMailServer;
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.user.util.UserUtil
import com.atlassian.jira.user.ApplicationUser
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
def searchProvider = ComponentAccessor.getComponent(SearchProvider.class)
def issueManager = ComponentAccessor.getIssueManager()
//def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
UserUtil userUtil = ComponentAccessor.getUserUtil()
//User user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
ApplicationUser user = userUtil.getUserByKey("abc");
log.error("User: " + user)
// edit this query to suit
def query = jqlQueryParser.parseQuery("Status in (open, PMR) AND fixVersion is EMPTY AND category = HyperWorks AND createddate < -2w AND issuetype = 'Role Mapper' AND project != 'QA Mainline Validation' AND 'PM Reviewed' is EMPTY AND assignee in (dbagul, scottg)")
//def query = jqlQueryParser.parseQuery("project = Hm and assignee = dbagul AND statusCategory != Done")
def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())
log.error("results count: " + results.getTotal())
def tickets = results.issues.collect { issueManager.getIssueObject(it.id) }
// log.error("tickets: " + tickets)
def filterUrlLink = "https://jira.abc.com/issues/?filter=30835"
//Result of JQL
def pmFieldValues = []
def assignee
// if you need a mutable issue you can do:
for (Issue issue in tickets) {
issue = issueManager.getIssueObject(issue.getId())
assignee = issue.getAssignee().getEmailAddress()
if(assignee != null){
log.error("Adding assignee: " + assignee)
pmFieldValues += assignee
}
}
// log.error("pmFieldValues: " + pmFieldValues)
def subject = "JIRA ACTION REQUIRED: Open tickets require PM attention"
log.error(subject)
//def body = "This week you have "+ count + " open issues that have not been addressed for more than two weeks." +"\n"+ "Please review, prioritize and process accordingly."+ "\n" + "Use the following JIRA filter to report open issues that are at least two or more weeks old:" +"\n" + "JIRA Search:" + "\n" + filterUrlLink + "\n" + "\n" + "Regards," + "\n" + "Michael Dambach"
def emailAddr = pmFieldValues.unique()
log.error("emailAddr: " + emailAddr)
def sendEmail(String assigneeEmail, String subject, String body) {
log.error("In sendEmail method")
SMTPMailServer mailServer = ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer();
if (mailServer) {
Email email = new Email(assigneeEmail);
email.setFrom("abc@abc.com")
email.setSubject(subject);
email.setBody(body);
mailServer.send(email);
log.error("Mail sent")
} else {
// Problem getting the mail server from JIRA configuration, log this error
log.error("sendEmailInactiveIssues - Error sending email!")
}
}
//log.error('I am here')
for (String assigneeEmail : emailAddr) {
log.error('Each assignee issue count email')
def jqlQuery = "assignee=\""+ assigneeEmail.split('@')[0]+ "\" and Status in (open, PMR) AND fixVersion is EMPTY AND category = hyperWorks AND createddate < -2w AND issuetype = 'Role Mapper' AND project != 'QA Mainline Validation' AND 'PM Reviewed' is EMPTY "
def query1 = jqlQueryParser.parseQuery(jqlQuery)
def results1 = searchProvider.search(query1, user, PagerFilter.getUnlimitedFilter())
def count = (results1.total)
log.error(count)
def body = "This week you have "+ count + " open issues that have not been addressed for more than two weeks." +"\n"+ "Please review, prioritize and process accordingly."+ "\n" + "Use the following JIRA filter to report open issues that are at least two or more weeks old:" +"\n" + "JIRA Search:" + "\n" + filterUrlLink + "\n" + "\n" + "Regards," + "\n" + "Michael Dambach"
log.error(body)
sendEmail (assigneeEmail, subject, body)
}
Thanks @Nic Brough -Adaptavist- I was able to send email to each assignee with their issue count in the email body. Above is the code which will be helpful for others.
Regards,
Deepali Bagul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.