Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JIRA: Automatically add an attachment to and issue after create

Adolfo Casari
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.
March 8, 2019

Hi,

I would like to add an attachment to an issue right after it has been created (in the Create postfunction).

The attachement is copied from a file that is located at a given path in the server's filesystem (In JIRA HOME directory for instance).

This is Jira Server. I know this can be accomplish with a groovy scriptrunner postfunction, but I am not familiar with the API involved in this case.

Thanks in advance,

 

1 answer

0 votes
Tom Lister
Community Champion
March 10, 2019

Hi @Adolfo Casari 

The api you need is the AttachmentManager to create a new attachment.

see https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/issue/AttachmentManager.html

This can be created using the ComponentAccessor.getAttachmentManager

see

https://docs.atlassian.com/software/jira/docs/api/7.1.7/com/atlassian/jira/component/ComponentAccessor.html

I’m not sure how familiar you are with groovy and scriptrunner so if you need more detail post specific questions on the thread

Suggest an answer

Log in or Sign up to answer