References:
https://answers.atlassian.com/questions/42844/jira-file-attach-listener
https://docs.atlassian.com/jira/6.2.7/com/atlassian/jira/issue/attachment/Attachment.html
Code - Work in Progress
package com.netic.listener import org.ofbiz.core.entity.GenericValue import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.comments.CommentManager import com.atlassian.jira.util.JiraUtils; import com.opensymphony.workflow.WorkflowContext; import com.atlassian.jira.event.issue.AbstractIssueEventListener import com.atlassian.jira.event.issue.IssueEvent import com.atlassian.jira.issue.attachment.Attachment //https://docs.atlassian.com/confluence/latest/com/atlassian/confluence/pages/AttachmentManager.html class ExampleListener extends AbstractIssueEventListener { @Override void workflowEvent(IssueEvent event) { def attachmentManager = ComponentAccessor.getAttachmentManager() def attachmentIds = [] String IssueType = event.issue.issueTypeObject.name String ProjectName = event.issue.getProjectObject().name String IssueKey = event.issue.key String EventId = event.getEventTypeId() System.out.println("Event: " + EventId) if (EventId == "2") { List changeItems = event.getChangeLog()?.getRelated("ChildChangeItem") changeItems.each {GenericValue gv -> if (gv["field"] == "Attachment" && gv["newvalue"]) { System.out.println(gv["newvalue"]) attachmentIds.add(gv["newvalue"]) //attachmentManager.getAttachment(gv["newvalue"]) } } //attachmentIds.each {attachmentId -> // Attachment attachment = event.issue.attachments.find {Attachment attachment -> // attachment.id == new Long(attachmentId) // System.out.println(attachment.getFilename()) // } // } } } }