...
...
...
...
...
...
Note |
---|
This document is obsolete. JMWE now supports copying of attachments across issues in the post-functions. |
Abstract
This code snippet copies
...
Attachments to the current issue from issues linked to it with a specific link type. Since currently copying and setting of attachments is not supported until JMWE-504 is implemented, you can use this snippet to copy the attachments
...
.
Logic
Fetch the attachments of the linked issues, linked to the current issue with a specific link type and use the AttachmentManager
to
...
copy them.
Snippet
Code Block | ||||
---|---|---|---|---|
| ||||
//DefineInitialize the attachmentManager import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.AttachmentManager AttachmentManager attachmentManager = ComponentAccessor.getAttachmentManager() //Define a variable to store 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()each{ attach += it.get("attachment") } } //Add each attachment to the issue attach.each{ attachmentManager.copyAttachment(it,currentUser,issue.key) } |
Info |
---|
By not specifying the link type, as |
Placeholders
Placeholder | Description | Example |
---|---|---|
<Link type name > | Name of the link type |
is cloned by |
Examples
The output outcome 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. Examplesthe copy of Attachments to an issue in the Scripted Groovy post-function:
- Copy the Attachments of the issue to current issue to the its newly created linked issue created using the Create issue post-function
- Copy the Attachments of the issue to a linked issue
References
Related articles
Filter by label (Content by label) | ||||||||
---|---|---|---|---|---|---|---|---|
|