Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automate Email When Number of Bugs per Assignee Reached

Mike Fink January 19, 2023

hey all,

I'd like to be able to create a Daily automation that checks the results of a JQL and sends an email to persons matching a Conditional criteria. Some details:

  • Frequency: Daily
  • Users: Engineering team (assigned to a specific project)
  • Criteria: More than 10 Bug tickets assigned
  • Outcome: Email each person who meets the above criteria

 

I can't quite get the Conditional part right. Here's a picture of what I have so far:

Screenshot 2023-01-19 at 3.24.30 PM.png

1 answer

1 accepted

1 vote
Answer accepted
Trudy Claspill
Community Champion
January 19, 2023

Hello @Mike Fink 

Welcome to the Atlassian community!

How is the rule not working for you? What does the Audit Log for the rule show?

Mike Fink January 19, 2023

Hi @Trudy Claspill

Simply put, I know there are 13 issues for the individual in the query so I know I should be getting an email if I set it up correctly. I got an email when I had some syntax errors and it straight up failed, but I don't get an email when it's "successful".

Hope that makes sense.

Side question - where do I see the audit log?

Trudy Claspill
Community Champion
January 19, 2023

What do you have in your Trigger? Is it just a time/schedule, or does it also include a JQL statement?

Are you explicitly naming a single Assignee in the JQL statement?

Where did you get information about the "count of" syntax you use in your comparison? I've not yet been able to find information on that.

 

The link to the Audit Log is above the components (shown in your image).

Screen Shot 2023-01-19 at 1.37.00 PM.png

Trudy Claspill
Community Champion
January 19, 2023

The way I would probably build this rule (unless I'm missing some requirement) would be:

Trigger: Schedule (with no JQL)

Action: Lookup Issues (put the JQL here to get the list of issues for a specific Assignee)

Advanced compare:

{{lookupIssues.size}} gives you the number of issues returned by the Lookup Issue action. Compare that to the threshold value

Action: Send email

Mike Fink January 19, 2023

The Trigger/Schedule has a JQL in it. It won't let me save it without it, for some reason.

 

Trigger: Schedule (2PM daily)

Action: Looks for list of Bugs by Assignee

Advanced Compare: if the count of issues returned is greater than 9, on to Action

Action: Send email

I figured out that I had to de-select "Only include issues that have changed since the last time this rule executed" on the When: Scheduled step (Trigger). It sends emails now, but it shoots me an email for every issue (13 total). That's kinda sub-optimal. 

I also tried the {{lookupissues.size}} approach but it wasn't successful for some reason :(

Trudy Claspill
Community Champion
January 19, 2023

When you use a Schedule trigger with a JQL the actions in the rule will be executed for each issue returned by the JQL.

You should be able to save the Schedule trigger without a JQL if you uncheck the "Run a JQL" box.

Screen Shot 2023-01-19 at 2.06.33 PM.png

I can help you debug the Lookup Issue problem, but you would need to show me the rule after you modified it for that. Also note that smart value needs to have a capital "I" for "Issues" - {{lookupIssues.size}

Mike Fink January 19, 2023

I get the following when I de-select "Run a JQL search" etc:

Error

  • The rule has been configured with components that require issues to be provided by the trigger. You need to use the option to run JQL to provide issues. The following components require issues: JQL condition

I also tried again with the {{lookupIssues.size}} and it didn't return anything. The JQL I'm using is as follows:

project = DB AND issuetype = Bug AND createdDate > "2019/12/01" AND (priority in (High, "Needs Triage", Normal, "Unbreak Now!") OR updatedDate > "2021/9/19") AND status != "Bug Deferred" AND statusCategory != done AND assignee = "username" ORDER BY priority DESC, updated DESC

 

Username is specified in the query though. I'm guessing my problem is either in the JQL or in the structure in general...

Really appreciate your help @Trudy Claspill!

Trudy Claspill
Community Champion
January 19, 2023

You would need to get rid of the "If issue matches JQL" component before you can save the Schedule Trigger with the JQL option unchecked.

Or you can start from scratch with a brand new rule.

Can you try constructing the rule this way and let me know what the results are?

Also, please let me know what you have set for the Rule Actor. That's on the Rule Details page.

Trigger: Schedule (without JQL)

Action: Lookup Issues

Advanced Compare:

{{lookupIssues.size}} greater than 9

Action: Send Email

Please show me the entire rule and the output of its execution in the Audit Log.

Also please take the JQL that you put in the Lookup Issues action and try it in the Advanced Issue Search screen to confirm that it is getting the issues you expect.

Mike Fink January 19, 2023

That worked! I appreciate your help so much, @Trudy Claspill

I have one more question, which hopefully isn't too hard.

Now that the automation works for one person, is there a way to expand it to an entire team in a project and have it send out emails to each team member matching that criteria?

I assume it would be something like:

 

Action: Lookup Issues and remove "AND assignee =" section of JQL

Advanced Compare: (same)

Action: Send Email to "Assignee"

Does that seem right?

Trudy Claspill
Community Champion
January 19, 2023

I don't believe that would be correct. Your comparison would be counting all the issues returned by the Lookup, which would be the total count for all Assignees.

And as written I don't think it would not send an email to each Assignee.

I'll have to think on this one a bit and get back to you. Off the top of my head I don't know how to recurse through a Lookup issue data set and get counts of subsets of issues based on the Assignee.

Like Mike Fink likes this
Trudy Claspill
Community Champion
January 20, 2023

For anybody that stumbles across this, the topic of automating notification for multiple assignees that have X number of issues assigned was started fresh in this post:

Automated-Email-to-Managers-Containing-JQL-Results 

Mike Fink January 23, 2023

hey @Trudy 

Slight problem - the email triggers regardless of the number of issues it finds. I ran it against a query that only returns 3 results, and it sent the email all the same. I think something is wrong with the Compare Two Values section:

 

Screenshot 2023-01-23 at 9.01.30 AM.png

Any thoughts? I have had to deactivate the automation :(

Trudy Claspill
Community Champion
January 23, 2023

The value you are comparing {{lookupIssues.size}} to should not be in curly braces.

Mike Fink January 23, 2023

thanks - played around with that after posting and can confirm that works now. Thanks @Trudy Claspill 

Mike Fink May 17, 2023

Update: I'm looking to do this via Jira python API now so it is more robust and executes programmatically. Makes it easier to update the query that way too.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events