Extract Confluence page url on creation via scriptrunner in jira

I'm currently using this wonderful functionality in scriptrunner plugin. - https://scriptrunner.adaptavist.com/latest/jira/interacting-with-confluence-from-jira.html

wherein part of my release process in jira, I'm creating confluence page for release notes.

Would like to know if it's possible to return the url on creation so that I can update in one of my "Release Notes" custom field. 


2 answers

1 vote

Thanos's answer should normally be sufficient, except if you have apostrophes or something in the URL.

The request returns the created page ID and link, you can get it using something like:

new groovy.json.JsonSlurper().parseText(response.responseBodyAsString)["_links"]["webui"]

That gives you the part of the link after the base url... the base url is also in there, but you know it already.

I don't know whether that stuff is intended for public consumption, so you could just get the page ID (key is "id" at the top level) and use /pages/viewpage.action?pageId=131077.

Hi Madhusudhan,

Yes you can store in a variable the link to the newly created confluence page because you know all the variables to just 'construct' the link, so...

def confluenceLink
    .createRequest(Request.MethodType.POST, "rest/api/content")
    .addHeader("Content-Type", "application/json"
    .setRequestBody(new JsonBuilder(params).toString())
    .execute(new ResponseHandler<Response>() {
    void handle(Response response) throws ResponseException {
        if(response.statusCode != HttpURLConnection.HTTP_OK) {
            throw new Exception(response.getResponseBodyAsString())
        } else {
			confluencePageUrl = "<a href='${confluenceLink.displayUrl.toString()}/display/${spaceKey}/${pageTitle}'>${pageTitle}</a>"
return confluenceLink

Please let me know if this does the trick


Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,329 views 14 20
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot