It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Help me to add attachment automatically when issue has been created Edited

Musku Nagaraju Mar 27, 2019

Hi Team,

I have one file in my C drive, when Issue has been created in Project ABC, the file should be attach automatically.


I am using below code but not working as I expected.


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueFieldConstants
import com.atlassian.jira.issue.attachment.TemporaryWebAttachment
import com.atlassian.jira.issue.attachment.TemporaryWebAttachmentManager
import webwork.action.ActionContext

def attachmentManager = ComponentAccessor.getAttachmentManager()

def user = ComponentAccessor.getJiraAuthenticationContext()?.getUser()

def bean = new CreateAttachmentParamsBean.Builder()
.file(new File("C:/Applications/Capgemini.jpg"))

2 answers

1 accepted

0 votes
Answer accepted
Matthew Clark [Adaptavist] Apr 02, 2019 • edited

Hi Musku

If you create a Scriptrunner "Custom script post-function" on the "Create" workflow transition and set the following script as the Last item on the list of POST functions it will allow you to add an attachment to issues on creation.

Script Link:

Add attachment from the Jira servers file system to the issue on creation

Note: You need to alter the script to fit the file path and name for your system.

Check the atlassian-jira.log if you have problems just in case you get permission errors.

Your original script was missing this line:


which means it would work once and then the file would be deleted so all other attempts would fail.

Further information on the CreateAttachmentParamsBean class here.



Musku Nagaraju Apr 02, 2019

Thanks @Matthew Clark [Adaptavist]  Working fine for me .

0 votes

Hi Masku

Can you tell me more about your requirement?

Are you trying to attach the same image to every new issue created or does the attachment change?

Is it always an image?

Is your Jira server running on windows and you want to pull in the file from within the Jira server itself or is this C drive on the client machine?

Musku Nagaraju Mar 29, 2019

@Matthew Clark [Adaptavist] ,I am trying to attach same one file in all issues that will never change.

It always file (.doc)

I am trying to pull this from client C drive, also I am fine this to pull from JIRA server as well, Help me on easy way.




Musku Nagaraju Apr 01, 2019

@Matthew Clark [Adaptavist] , Can you please provide your inputs on this.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Jira

Try Jira Cloud for Outlook: Organize your work without leaving your inbox

Hi Atlassian community, My name is Max and I work on the product integration team at Atlassian. I am pleased to announce the early access program for the Jira Cloud add-in for Outlook. This add-in...

1,792 views 3 15
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you