Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Clone issue with attachments

fabio marcelo May 21, 2014

Hi all,

I am trying clone an issue with attachment and move it for other project.

I got clone the issue and move for other project , but the attachments were not copied for the new issue.

I am using groovy runner(version 1.7.14), my JIra version is 4.4.5.I have a post- function in my workflow that call the script "Clones an issue and links".

How can copy the attachment from an issue for other, through Post-Function ?

Thanks in Advance

Best Regards

Fabio

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
fabio marcelo May 25, 2014

Hi Kostas,

I updated the version from Script Runner to 2.0.7, and it worked.

Best Regards

Fabio

Tsol
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 25, 2014

Hi Fabio,

that's good!

Well Done

0 votes
Tsol
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 21, 2014

Hi there,

have a look in this question. I think that if you add some code in additional actions you will get what you want.

Hope that helps.

fabio marcelo May 21, 2014

Hi Kostas,

Thanks for your help.

I tried put the code mentioned there, but it not worked too.

Sorry, I am not familiar with this language.

Best Regards

Fabio

Tsol
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 21, 2014

I'll try to reproduce the case a bit later....

fabio marcelo May 21, 2014

Thanks a lot , for your help.

Best Regards

Fabio

fabio marcelo May 22, 2014

Hi kostas,

I included the following code in the "Additional issue actions" from
Clones an issue and links.


List attachments = attachmentManager.getAttachments(oldIssueGV);
int attachmentsSize = attachments.size();
for (int i = 0; i < attachmentsSize; i++) {
Attachment attachment = (Attachment) attachments.get(i);
File attFile = AttachmentUtils.getAttachmentFile(attachment);
attachmentManager.createAttachment(attFile, attachment
.getFilename(), null, assignee, newIssueGV);
}

It showed the following error:

unable to resolve class Attachment
@ line 4, column 14.
Attachment attachment = (Attachment) attachments.get(i);
^

Script5.groovy: 4: unable to resolve class Attachment
@ line 4, column 27.
Attachment attachment = (Attachment) attachments.get(i);
^

2 errors

Please , the place(Additional issue actions, from script runner) where i am putting the code is correct ?

Thanks in Advance

Tsol
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 22, 2014

Hi Fabio,

to be honest i didn't find the time to test due to heavy workload.

I'll try to have a look later today and i'll keep you updated.

Cheers

0 votes
Gregory Kneller
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 21, 2014

You can do it with JJUPIN plugin (instead of ScriptRunner)

fabio marcelo May 21, 2014

Hi Gregory,

This plugin is free ?

Best Regards

Fabio

Gregory Kneller
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 21, 2014
0 votes
fabio marcelo May 21, 2014

Hi All,

I tried put this code below in "Additional issue actions" from script
Script: Clones an issue and links, but it not worked.

*****************************************************************

AttachmentManager attchMgr = ComponentAccessor.getAttachmentManager();
AttachmentPathManager pathManager = ComponentAccessor.getAttachmentPathManager();
List<Attachment> attchments = attchMgr.getAttachments(sourceIssue);
if (!attchments.isEmpty()) {
for (Attachment attachment : attchments) {
String filePath = PathUtils.joinPaths(pathManager.getAttachmentPath(), sourceIssue.getProjectObject().getKey(), sourceIssue.getKey(), attachment.getId().toString());
File atFile = new File(filePath);
if (atFile.exists()) {
try {
if (atFile.canRead()) {
attchMgr.createAttachmentCopySourceFile(atFile, attachment.getFilename(),attachment.getMimetype(), attachment.getAuthor(), issue, null, attachment.getCreated());
}
} catch (SecurityException se) {
System.out.println("Could not read attachment file. Not copying. (${se.message})");
} catch (AttachmentException e) {
e.printStackTrace();
}
} else {
System.out.println("Attachment file does not exist where it should. Not copying.");
}
}
}

*****************************************************************

I ve got the following error message:

And the logs :

2014-05-22 07:38:51,915 http-8080-9 ERROR fcontri 458x4706x1 uooma3 10.13.5.250 /secure/WorkflowUIDispatcher.jspa [atlassian.jira.workflow.OSWorkflowManager] Caught exception while attempting to perform action 1281 from workflow 267410 on issue 'TEST390-22'
com.opensymphony.module.propertyset.PropertyImplementationException: Property 'se' not found

Please could you help me ?

Thanks in Advance

Best Regards

Fabio

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events