How to create a confluence page from Jira Cloud using Scriptrunner

Jibu Chacko January 24, 2021

Hi,

I am using Jira Cloud and Confluence Cloud

I found examples for creating Confluence Page from a Jira Server using ScriptRunner.

https://scriptrunner.adaptavist.com/6.17.0/jira/interacting-with-confluence-from-jira.html

But most of the libraries in the example are not available for the Cloud version. For eg `com.atlassian.applinks.api`. I am not able to use application links to authenticate Jira to Confluence. Can someone shed some light?

2 answers

1 accepted

0 votes
Answer accepted
Kristian Walker (Adaptavist)
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 25, 2021

Hi Jibu,

I can confirm that the example you have linked to will not work as this for Jira Server and the APi's are different between the Cloud and Server versions of ScriptRunner, due to the fact Atlassian only provides a Rest API in Jira Cloud and not a Java API like the sever version contains.

This means for ScriptRunner for Jira Cloud you should always refer to its own documentation located here and sI can confirm that we have an example script located in the documentation page here which can be run from the Script Console inside of ScriptRunner for Jira Cloud.

Using this script you will be able to see how to create a Confluence page and you can use this script as a reference guide to help you to create the scripts that you require.

Regards,

Kristian

Jibu Chacko January 25, 2021

@Kristian Walker (Adaptavist)  Thanks for pointing that out. 

 

However I see you need Scriptrunner for Confluence is also needed for this to work which is not true in my case. Can we not use AppLinks to authenticate Jira Cloud and Confluence and avoid incorporating credentials in the script?

I know it works for Jira Server and Confluence Server as mentioned here using the ApplicationLink API

Kristian Walker (Adaptavist)
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 25, 2021

Hi Jibu,

Thank you for your response.

I can confirm if you do not have both plugins installed then as the page says then you can specify the full URL to your instance in the Rest API call and you can include authorisation to authenticate with Confluence as the API's are different between cloud and server so you cannot use APP links as you can do on Server.

I can confirm for authorisation you need to use a token as mentioned in the Atlassian API docs located here which explains how to get an API token.

Also, I can confirm the example located here which shows how to specify an  API token for authorisation when making an API call as part of the header of the rest call.

Regards,

Kristian

Andrey Permyakov January 23, 2022

@Kristian Walker (Adaptavist) 

Good day
I was able to create a page with a "Wiki" storage type. But I was not able to link back to the Jira issue on the page. How can this be done with Rest API?

In "Storage" type work:

https://domain.atlassian.net/browse/JIRA-1

But "Description" did not save "Wiki" markup.

0 votes
Kate Kabir
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.
January 24, 2021

Thank you for your question.

I can confirm that to link to a Confluence page from ScriptRunner for Jira Cloud that your script would need to make a rest call to the Create or update remote issue link API which Atlassian provide and is documented here.

I can confirm we have an example of how to call this endpoint inside of the ScriptRunner for Jira Cloud documentation page located here which shows an example of how to add a link to an external URL.

I can confirm that you will be able to take this example and to use it as a reference guide and to modify it by updating it to set the globalId value which would refer to the page in Confluence as the API documentation page linked to above mentions.

Please note that we are unable to provide you with an exact script to achieve this requirement as our SLA does not cover custom coding but you can use the examples provided as a reference to create the script that you require, and we would advise asking a question on the Atlassian Community located here if you require assistance with coding the script.

I hope this helps.

Kind regards,

Kate

Jibu Chacko January 24, 2021

@Kate Kabir What I am trying to achieve here is to create a confluence page from Jira Scripttunner. The example here does not work for Jira Cloud. Can you point me the cloud version of the same example? 

Jibu Chacko January 24, 2021

PFA The error I am facingScreenshot 2021-01-25 at 12.22.17 PM.png

Kate Kabir
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.
January 25, 2021

Hi Jibu.

The link that you have provided is for Jira Server. This will not work in the Jira Cloud environment/integration. The information that I have provided earlier is for you to link to a Confluence page from ScriptRunner for Jira Cloud environment. The link that I have provided is specific to Jira Cloud integration. 

The only way to achieve this, you will need to make a rest call to the Create or update remote issue link API which Atlassian provides and is documented here.

I can confirm we have an example of how to call this endpoint inside of the ScriptRunner for Jira Cloud documentation page located here which shows an example of how to add a link to an external URL.

I can confirm that you will be able to take this example and to use it as a reference guide and to modify it by updating it to set the globalId value which would refer to the page in Confluence as the API documentation page linked to the above mentions.

Thank you. 

Kind Regards

Kate

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events