Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Get an PDF Attachment file from a Jira Issue using Groovy script in ScriptRunner

Get an PDF Attachment file from a Jira Issue using Groovy script in ScriptRunner.

I am trying to get the attachment of a Jira issue in Jira Service Management(Server) using Groovy Script under ScriptRunner plugin.

Please help me in finding the solution.

Here is the code I am using now:

1). Getting  java.lang.StackOverflowError with this code: 

List attachments = aM.getAttachments(issue)

def attachmentID;
File attachmentFile;

if (!attachments.isEmpty()) {
for (Attachment a in attachments) {
String fileName=a.getFilename()
attachmentID = a.getId()

String storePath=pM.getAttachmentPath()
def attachmentFilePath = new File(storePath).path
attachmentFile= new File(attachmentFilePath,fileName)


2). This gives NullPointer Exception as File object is coming as "null"

File file = ComponentAccessor.getComponent(FileSystemAttachmentDirectoryAccessor.class).getAttachmentDirectory(issue).listFiles().find({
File it->

log.warn("File exists!!!");

Not sure what I am missing.

NOTE : I am new to Jira and Groovy.

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

New Cloud Apps Roundup - April 2021

Atlassian's marketplace partners have had a very productive start to 2021! Since our last roundup, our developer community has added over 160 new cloud apps to the Atlassian Marketplace to help you...

317 views 3 20
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