Hi everyone,
I am using the wonderful Script Runner plugin and have a post-function set up to clone an issue into another project. I had wanted to NOT copy any of the attachments to the new issue, or alternately delete all the attachments from the new issue.
My first thought was adding something to the "Additional issue actions" section at the bottom for groovy script that will delete all attachments, but I'm not sure about what to write here or the syntax.
Does anyone know how to delete all attachments on an issue in Groovy?
Thanks in advance,
Will
Hello....
I'm afraid, looking at the code, that the attachments are copied after the additional code is run... this may have been a mistake on my part, can't remember. Not sure why I didn't put in provision for copying attachments to be optional.
You could either modify the source... just remove one line from com.onresolve.jira.groovy.canned.workflow.postfunctions.CopyIssueWithAttachments, no compilation necessary, or, add another script post-function pointing to a file containing this code:
import com.atlassian.jira.component.ComponentAccessor def attachmentManager = ComponentAccessor.getAttachmentManager() attachmentManager.getAttachments(issue).attachments.each { attachmentManager.deleteAttachment(it) }
Completely untested, but should work.
Jamie, can you provide some guidance on where to find the version of com.onresolve.jira.groovy.canned.workflow.postfunctions.CopyIssueWithAttachments so that it can be modified in my existing plugin install? I attempted to use the above suggestion to delete the attachments on the Create transition of the cloned (new) issue, but it didn't do anything. I am using version 2.1.9 of Script Runner and 5.2.8 of Jira. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie,
Trying to implement your workaround as this is something we need. We are running Script Runner 2.1.15 and JIRA 6.0.8. This comment is quite old but I don't see the option to remove attachments in the clone issues post function so I'm assuming this is still a potentially required workaround?
We get an error trying to run this script and i'm wondering if things have changes since this comment was posted?
javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: Exception evaluating property 'attachments' for java.util.ArrayList, Reason: groovy.lang.MissingPropertyException: No such property: attachments for class: com.atlassian.jira.issue.attachment.Attachment
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jamie, can you provide some guidance on where to find the version of com.onresolve.jira.groovy.canned.workflow.postfunctions.CopyIssueWithAttachments so that it can be modified in my existing plugin install? I attempted to use the above suggestion to delete the attachments on the Create transition of the cloned (new) issue, but it didn't do anything. I am using version 2.1.9 of Script Runner and 5.2.8 of Jira. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jered, I have the same problem that you.You got to make this work. Jamie, Please where i can put this groovy code ? Best Regards
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.