...
...
...
...
...
...
Abstract
This code snippet copies the attachments of the first linked issue to the current issue. Since currently copying and setting of attachments is not supported, you can use this snippet to copy the attachments of an issue.
Logic
Fetch the attachments of the issue and use the AttachmentManager
to set the attachments of the issue.
Snippet
Code Block | ||||
---|---|---|---|---|
| ||||
//Define the attachmentManager import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.AttachmentManager AttachmentManager attachmentManager = ComponentAccessor.getAttachmentManager() //Define the attachments variable def attach = [] if(issue.getLinkedIssues("<Link type name>")){ //Fetch the attachments of the linked issue and store them in the attach variable attach = issue.getLinkedIssues("<Link type name>").first().get("attachment") } //Add each attachment to the issue attach.each{ attachmentManager.copyAttachment(it,currentUser,issue.key) } |
Placeholders
Placeholder | Description | Example |
---|---|---|
<Link type name > | Name of the link type name | is cloned by |
Examples
The output of the code snippet is a collection of attachments which you could use in a Groovy expression, for example. to Set the Attachments of a linked issue in one of the Set field value post-functions or the Create issue post-function under the Set fields of new issue section. Examples:
- Copy the Attachments of the issue to current issue to the newly created issue
- Copy the Attachments of the issue to a linked issue