Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×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.
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
https://docs.atlassian.com/software/jira/docs/api/REST/7.12.0/#api/2/attachment-getAttachment
And a Confluence REST API endpoint to create attachments
https://docs.atlassian.com/ConfluenceServer/rest/6.12.1/#content/{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 = Unirest.post("/rest/api/2/issue/${clonedIssue.id}/attachments") .header("X-Atlassian-Token", "no-check") .field("file", is, ContentType.create(attachment.mimeType), attachment.filename) .asObject(List) 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
Vamshee
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And ... it's back
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think you could use the App Link set up between your Jira and your Confluence to modify Confluence pages
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register Now
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.