Attach single file to multiple Issues

heena March 22, 2015

How can we attach a single source file to multiple issues in JIRA.

2 answers

3 votes
Anuj Sapate July 19, 2016

@heena, @Nic Brough [Adaptavist] Yes this can be achievable using latest JIRA API.

I've did the same in following way:

 

CreateAttachmentParamsBean.Builder capbBuilder = new CreateAttachmentParamsBean.Builder();
capbBuilder.file(newAttachment);
capbBuilder.filename(fileName);
capbBuilder.author(loggedInUser);
capbBuilder.copySourceFile(true);//Set this property true and you're free to attach the same file to multiple issues.
capbBuilder.issue(mIssue);                    

CreateAttachmentParamsBean capb = capbBuilder.build();                                                    
attachmentManager.createAttachment(capb);

 

I hope this will help somebody else whoever looking for same implementation. 

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 19, 2016

Just to be clear, your code is not attaching one file to several issues, it's attaching copies of the file to multiple issues.  The "true" flag there just means "don't delete the original file"

Anuj Sapate July 19, 2016

Agreed. While attaching file to the issues, it creates a separate copy of that source file without deleting source file from the directory.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 22, 2015

You can't.  JIra's attachment system doesn't support anything like that, it's a simple flat "this file the user provides is attached to this issue, and stored on the file system underneath that issue".  If you want to attach the same file to several issues, you have to attach it to each one separately.  Obviously, these will now be totally independent separate files.

If you want to reuse the same file without spawning copies, then you need to store the file somewhere and link to it instead of attaching it.  Jira's "web link" is quite handy for that (although the file will not behave like an attachment), and can even link back to another JIRA issue

SS July 6, 2020

Question. Does the back-end use deduplication, or will there actually be multiple copies of the file on the server?

Sorry for necro.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 6, 2020

Necroposts are not a concern when you've read the question and it's still relevant.  It's the adverts and failure to read the question and response we don't like.

Yes, you're right, there will be multiple copies of the same file on the server.  With different physical names.  Jira's attachment system is a simple directory tree with a copy of each upload in a directory related to each issue that has an attachment.  There's no deduplication or linking in place.

Suggest an answer

Log in or Sign up to answer