Automation: Sending an email with lists of issues

Daria H_ August 31, 2020

Hello, 

Could anyone knows if it is possible to send scheduled emails with multiple lists of issues using automation rules in Jira Server?

 

The concern is that I am trying to get an everyday report in which I will get lists of issues with different priorities. I also need to display the issue's status, key and summary. So, what I expect to get : 

Issues with High priority:

  • 111 - Test - In progress
  • 112 - Testtest - On hold
  • ...

Issues with Medium priority:

  • 221 - Test test - To do
  • 222 - Test testtest - Closed
  • ...

...

 

I know how to use one JQL in one email, but I don't know how to use two of it. Maybe someone solved such kind of problems using Scriprunner's custom emails or something like that?

 

4 answers

2 votes
Florian
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 31, 2020

Hi, that’s a built in function. You don’t need any automation plugins nor administrative rights.

Daria H_ September 1, 2020

Hi @Florian 


Thank you for your response.

Unfortunately, this method does not solve my problem because I need to see two different JQL requests which won't be mixed (as for instance when you subscribe to the filter which consists of two filters). And I also need to add some text info into the email(

0 votes
Kevin Bui
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 1, 2020

Hi @Daria H_

I can confirm that what you're looking to do is currently not possible using automation rules in Jira Server. It is, however, possible to do this in Jira Cloud using the Scheduled trigger combined with the Lookup issues action.

0 votes
Boris Berenberg - Atlas Authority
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.
September 1, 2020
0 votes
Gustavo Félix
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 31, 2020

@Daria H_  Hi Daria, I have ScriptRunner . You can easily do that with an escalation service. There you can execute some jql's inside the groovy code.

And send the email with the information that you need.

Im not sure how to do it without a plugin. You can get a trial license to see if its what you need.

Daria H_ September 1, 2020

Hi @Gustavo Félix

Thanks for the response. 

I have ScriptRunner and I saw this feature, but I've never used Groovy. Do you have some examples of how to use it and what should I write here? 

Gustavo Félix
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.
September 1, 2020

Hi @Daria H_ 
You can take this as an example.

It executes a jql and then iterates the results(issues).

Counts the issues with high priority .

And then sends an email. You have to configure an smtp outgoing mail server.

Hope it helps you.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.mail.Email
import com.atlassian.mail.server.SMTPMailServer
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.index.IssueIndexingService

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
List [] issues = null
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService)

def queryJql = "project = test"

SearchService.ParseResult parseResult = searchService.parseQuery(user,queryJql)
def searchResult = searchService.search(user,parseResult.getQuery(), PagerFilter.getUnlimitedFilter())

List<Issue> results = searchResult.getResults()
log.warn(searchResult.getTotal())
int count = 0;
results.each { issue ->
if(issue.getPriority().getName().equals("High")){
count++;
}
}
log.warn "High->" + count

SMTPMailServer mailServer= ComponentAccessor.getMailServerManager().getDefaultSMTPMailServer()
if(mailServer){
Email email = new Email("pobox@test.mx")
email.setFromName("Gustavo")
email.setFrom("gfelix@test.mx")
email.setSubject("Information")
email.setBody("Count: "+ count.toString())
email.setTo("pobox@test.mx")
mailServer.send(email)
}

Suggest an answer

Log in or Sign up to answer