Get the HTML content of a specific issue using ScriptRunner


I would like to get the Attachment HTML section of a specific issue in script

is there a way to retrieve the issue HTML using scriptrunner?



1 answer

0 votes

I'm not sure what you mean by "the attachment html section", but I will guess that what you mean is "the displayed panel headed attachments when I look at an issue"

That is generated when you view the issue, not stored, so there's nothing to "get".  If your script needs to use the raw html of that panel, it's going to have to replicate the logic that generates it all.

Hi Nic,

I would like to display the parent attachment section on the sub task issue as a script field that take the parent HTML and returns the attachment element




Ok, a scripted field supports html output, so you can embed a lot of the table html you need in there.  Then your script will need to grab the parent issue from the current one, and iterate through the attachments on it to get the details from them.

You'll also want to write a listener that can catch attachment updates from the parent issues and trigger a re-index on the sub-tasks.

Hi Nic

maybe I didn't explained it right 

I would like to do something like this:

We have 2 issues 139 (parent) and 140 (sub)

and I would like to show the parents attachment under the sub issue using script field

is it possible?


I Capture-attachment field.PNG

Er, that's what I specified.


Hi Nic

I actually tried to write a script that get the HTML of the issue but the script seems to get into infinite loop or something and don't return anything

if I change the URL to some general url ( for example) i can get the HTML

why is that?

String url = "http://localhost:8080/browse/TEST-11/";
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
String userCredentials =  "user:pass" ;
String basicAuth = "Basic " + new Base64().encode(userCredentials.getBytes());
con.setRequestProperty("Authorization", basicAuth);
int responseCode = con.getResponseCode();
BufferedReader input = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = input.readLine()) != null ) {
return response.toString()


You need to stop thinking in terms of "getting the html" and build it for yourself.  If you try to fetch from the same place, you've put yourself into an infinite loop.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,111 views 4 9
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you