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

How can I copy attachments from a JIRA Issue to a Confluence page on transition?

I am using JIRA for approval process and when the attachments are transitioned to "Done" I would like to use ScriptRunner (or maybe something else?) to copy the attachments from the JIRA issue into a specific Confluence Page. 

4 answers

1 vote

Why would that be helpful? I would use references rather than copying the actual data

Cloud or Server? Might be possible with Script Runner in cloud and probably also server with the REST API only - but I haven't tried it.

How's your scripting? I'm not going to go to deep into the scripting but I will post some snippets which might help you.

There's a Jira REST API endpoint to get attachments

And a Confluence REST API endpoint to create attachments{id}/child/attachment-createAttachments

So from Jira you could have a Workflow Postfunction or ScriptRunner Listener to run a groovy script to get attachments from the Jira issue and Post to a confluence page.

You can download the attachment(s), keeping them in memory, and upload them elsewhere, still from memory. Here's a code snippet of copying attachments from one jira ticket to another in this fashion. (The language is Groovy).

if (issue.fields.attachment) {
    issue.fields.attachment.collect { attachment ->
        def url = attachment.content as String
        url = url.substring(url.indexOf("/secure"))
        def is = Unirest.get("${url}").asBinary().body
        def resp ="/rest/api/2/issue/${}/attachments")
                .header("X-Atlassian-Token", "no-check")
                .field("file", is, ContentType.create(attachment.mimeType), attachment.filename)
        assert resp.status >= 200 && resp.status < 300

The only thing I am not sure about is that I think that scriptrunner limits what API's you can call - I am pretty sure you can't make HTTP requests to arbitrary services (google, facebook etc). I don't know how constrained this limitation is.

The other challenge to solve is unless you are posting attachments to the same confluence page every time then you would need a way to dynamically specify which confluence page it should go to. You could store the ID or URL of the confluence page in a custom field on the issue and then read the value and interpolate it into the url.

Actually I don't think it will work talking to another system using script runner as I am pretty sure script runner talks to your Jira using JWT and you wont be able to auth with the confluence - that might be a question to raise with Adaptavist support.

You could use Webhooks to talk to your own Webservice which listens for events / webhooks from Jira and then once again uses the REST API to get the attachments from Jira and push it to confluence.

The web service wouldn't have to be very big - maybe 30 lines of python running as a flask application. But it comes with the additional overhead of needing to be hosted.

The short answer is I think it's definitely possible depending on how far you are willing to go and what you consider reasonable effort. Maybe someone else in the community has a simpler solution?

...did my original comment get deleted?

And ... it's back

Like Simon Merrick likes this

I think you could use the App Link set up between your Jira and your Confluence to modify Confluence pages

Weird, anyway seeing your response I tend to agree - this 'solution' would be duplicating data.

My answer addresses the question of 'could I?' but not 'should I?'

I am looking solution for the similar problem. I have a requirement similar to this. All the work is done JIRA but the attached documentation should be Confluence. People will be working off JIRA but all the attachments should go into Confluence with JIRA issue number, date and time.

I was hoping automation for JIRA would help (still waiting on approvals).

Thank you


Suggest an answer

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

Jira issue check and more advanced commit verifications for Bitbucket DC

Pre-receive hooks that verify the Git commit message, the modified files, and implement similar code change controls used to be requirements of large enterprises working in regulated industries only....

19 views 0 0
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