Here's how to copy comments with attachments to the last linked issue:
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
def commentManager = ComponentAccessor.getCommentManager()
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def attachmentManager = ComponentAccessor.getAttachmentManager()
def user = ComponentAccessor.getJiraAuthenticationContext().loggedInUser
def issue = event.issue as Issue
lastComment = commentManager.getLastComment(issue)
body = lastComment.getBody()
author = lastComment.getAuthorApplicationUser()
def linkedIssue = issueLinkManager.getLinkCollection(issue, user).getAllIssues().last()
lastAttachment = attachmentManager.getAttachments(issue).last()
attachmentManager.copyAttachment(lastAttachment, user, linkedIssue.key)
commentManager.create(linkedIssue, author, body, false)
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.