Here is a simplest version that I can share,
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.util.AttachmentUtils
def issueManager = ComponentAccessor.getIssueManager()
def attachmentManager = ComponentAccessor.getAttachmentManager()
def issue = issueManager.getIssueObject("<DESIRED_ISSUE_KEY"); // e.g. SP-1
def attachments = attachmentManager.getAttachments(issue)
attachments.each{ attachment ->
def fileName = attachment.fileName
def filePath = AttachmentUtils.getAttachmentFile(attachment)
def attachmentFile = new File(filePath)
}
Important portion here are, fetching attachment object and getting it's file path using AttachmentUtils helper class (this is because attachments are stored in file system using special directory structure)
Once you have attachment file you can use it as you wish.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.