Forums

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

ScriptRunner add attachment in jira SM cloud?

Sten W April 1, 2025

Can some please explain how to, using Groovy in ScriptRunner for Jira Cloud, copy an attachment from a parent to child workitems i have created? 

I found a response claiming HAPI's Issue would have a addAttachment() but the IDE doesn't recognize it nor is it in documentation.

Also, can attachment be copied without first storing as file somewhere?

(Sidenote: it's disturbing that most scripts found are for Server/DataCenter, not Cloud)

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Bobby Bailey
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.
May 29, 2025

HI @Sten W , 

My name is Bobby I am a Senior Customer Success Manager with ScriptRunner. 

Apologies with the confusion with the documentation given in the other answer. The link provided which shows Javascript is our integration tool, ScriptRunner Connect, not ScriptRunner for Jira. 

Also, references you have seen to the addAttachment function in HAPI are for DataCenter. While HAPI exists on Datacenter and Cloud, its much younger on Cloud so we are working to develop it to match DC, but its not there yet. 

I am not sure if you got the answer from support, but you can copy attachments over with this script: 

https://bitbucket.org/Adaptavist/workspace/snippets/rqgoLX

You are correct our example scripts do lean heavily towards DC right now. This is (as with HAPI) something we are looking to improve. I will feed back to the team to see if we can get this script added as an example script, as it is a very useful one. 

Does this help?

Kind regards, 

Bobby

0 votes
Fabio Racobaldo _Herzum_
Community Champion
April 1, 2025

Hi @Sten W ,

probably you are looking a scriptrunner guide for JIRA Data Center (https://docs.adaptavist.com/sr4js/8.8.1/hapi/work-with-attachments ). Please take a look to the following guide for a Cloud instance https://docs.adaptavist.com/src/latest/scripting/code-snippets/working-with-attachments

Hope this helps,

Fabio 

Sten W April 1, 2025

No, not looking FOR Data Center. 

And your second link is about javascript which i can't see how i would somehow inject in Groovy code environment where my Groovy script runs under "ScriptRunner for Jira Cloud". 

Perhaps this Atlassian forum only concerns the implementation of ScriptRunner inside Jira, not the use of it?

So while in Grovy i have addedChildIssue  (a Issue), how can i add a copy of the attachment from it's parent (what triggered by ScriptRunner listener) to it?

I guess i'll try on adaptavist's support channels. Their pages is full of sales-pitches with little substance with Documentation sections full of "see how easy to do... simple stuff" but little more in-depth details.

I would like to have attachment-processing info on https://docs.adaptavist.com/sr4jc/latest/hapi/work-with-issues

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events