JIRA – Email notification on file attachment

One of the issues that I find with JIRA, is that you cannot realistically have “notification on issue update” enabled, due to the amount of emails you will get that don’t have useful information.

The way I got round this is to create a custom email listener.

  • Go to “Administration” > “Plugins” > “Script Listeners”.
  • Create a new listener as “Send a custom email”
  • Events: Issue Updated
  • Projects: Choose a project of your liking, or choose All Projects
  • Condition: attachmentManager.getAttachments(issue) && changeItems.any {it.get(‘field’)==’Attachment’} && ! issue.securityLevel
  • E-Mail Template: This ticket has an update regarding attachments.

    If a new attachment has been addded, it will be attached above. Latest attachment updated by $currentUser

    If an attachment has been deleted from the JIRA ticket, this is a notification of that action.

    Click here to view ticket: ${baseUrl}/browse/$issue.key

    Please do not reply to this email. This is a notification only.

  • Subject template: ($issue.key) $issue.summary
  • To Issue Fields: assignee reporter watchers
  • Include attachments: New

This should allow you to get a notification for all new and deleted attachments, as well as an email with a link to the issue.


10 thoughts on “JIRA – Email notification on file attachment

  1. This is amazing! I’ve literally been searching for a solution for this for months and stumbled across this site.

    I am getting the following error however. Believe it’s related to the ‘field’ entry, but can’t quite work out what my equivalent should be. Are you able to offer any insight?

    org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script1.groovy: 1: Invalid variable name. Must start with a letter but was: ‘field’ . At [1:68] @ line 1, column 68. e) && changeItems.any {it.get(‘field’)== ^ 1 error

    • Glad I could help!

      Make sure you be careful when you copy and paste from WordPress. It seems to like smart quotes instead of “dumb quotes”. So check your quotes, and let me know!

  2. Hi,

    Try for great post!

    I’am having same problem to send custom email when attachments are added.

    I have done this and changed quotes:
    Condition: attachmentManager.getAttachments(issue) && changeItems.any {it.get(“field”)==”Attachment”} && ! issue.securityLevel

    Also tried this:
    Condition: attachmentManager.getAttachments(issue).size() != attachmentManager.getAttachments(issue).size()

    Neither are working, any tips?

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s