Forums

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

send email when security level is specific

Teemu Niemi May 7, 2019

My coding experience with scriptrunner is bad. I have been looking for solution for this problem couple weeks now and I just can't get it sorted.

First user wanted watchers to be add to issue if issue security level is specific. Luckily @PD Sheehan has been helping.

I just want to get email notification in some way when issue is created and it's security level is "Dangerous" (issue security level id is '10200').

Best solution is of course solution where email notification is sent always when security level is changed to this "Dangerous".

I can use scriptrunner scripts and we have Automation Lite in use, but so far Scriptrunner seems to be better to begin with.

1 answer

0 votes
PD Sheehan
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 8, 2019

Here is how I would approach the entire problem

  1. Create a custom event: Admin >System Events
    • Name it to something clear like "Dangerous Issue Security Used"
    • Pick one of the email template (there isn't much choice there)
  2. Create a scriptrunner script listener: Fires an event when a condition is true
    • Projects: select relevant projects or All Projects
    • Events: select Issue Create and Issue Updated
    • condition script: see code lock below
    • Event: select the event created under #1
  3. In your project notification scheme, assign groups, users or project role to the event you created in #1

This setup will let you control the distribution of those email on a per-project or per-notification scheme basis.

The downside is the inability to use custom text in the email. I'll offer some options below.

First the condition script:

issue.securityLevelId == 10200 && changeItems.any{
it.field == 'security'
}

 

If you want a more custom email and you don't have another add-on that can listen to jira events (like JEMH), you can use another scriptrunner listener: Send a custom email

The nice thing here is that you can create multiple of such send email events with different parameters and configuration.  But the bad thing is that you have to maintain it separate from the standard notification scheme.

Another option would be to skip #1-3 above and just go with a send a custom email listener with the same code I listed above. 

Suggest an answer

Log in or Sign up to answer