Working with attachments
Attachments feature is a useful feature in JIRA, and it sometimes helps to manage the attachments on an issue through the JIRA APIs. In this recipe, we will learn how to work with attachments using the JIRA API.
There are three major operations that can be done on attachments - Create, Read , and Delete. We will see each of them in this recipe.
Getting ready...
Make sure the attachments are enabled in your JIRA instance. You can do this from Administration | Global Settings | Attachments, as mentioned at http://confluence.atlassian.com/display/JIRA/Configuring+File+Attachments.
How to do it...
All the operations on the attachments can be performed using the AttachmentManager
API. The AttachmentManager
can be retrieved either by injecting it in the constructor or from the ComponentManager
class, as shown:.
AttachmentManager attachmentManager = ComponentManager.getInstance().getAttachmentManager();
Creating an attachment
An attachment can be created on an issue using the createAttachment...