The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

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 Champions.
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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

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