• Community
  • Products
  • Jira Software
  • Questions
  • How to automatically create a confluence page based of a template when a jira subtask is created and also link to it, through a custom script in script runner?

How to automatically create a confluence page based of a template when a jira subtask is created and also link to it, through a custom script in script runner?

Shagufta Gurmukhdas November 22, 2016

I have a groovy script in which I am dynamically creating subtasks based on some conditions. I want each of these subtasks to have a link to a confluence page automatically created, from a template(which I have already created). How do I do that? No other add-on than script runner is allowed. I have seen many such questions online, but none of them provide with a way to do it with scriptrunner and using a confluence template .

5 answers

1 vote
Daniel Ciarlette January 12, 2018

Has anyone found a REST or Scriptrunner solution for this yet?

1 vote
Jonny Carter
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.
November 30, 2016

So, it sounds like you need to do two things when the sub-task is created:

1) Create a new page from a template in Confluence

There does appear to be a REST endpoint in Confluence's API that lets you create an instance of a template with a POST request. You can call it using the app link configuration; see the documentation on interacting with other Atlassian apps.

If Confluence's current REST endpoint doesn't cut it, you could use ScriptRunner for Confluence to add a scripted REST Endpoint that you can call from JIRA.

2) Link the sub-task to the newly created Confluence page

You could simply embed a JIRA macro in the new Confluence page. Assuming JIRA and Confluence are linked, this should create a remote link in JIRA as well. See the docs on interacting with confluence from JIRA.

You could also create the remote link inside JIRA using the Java API for it.

Steven F Behnke
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.
November 30, 2016

Hey sweet! That Template API is new! 

Edit: Oh BOO it's Cloud-only for now.

Jonny Carter
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.
December 7, 2016

Bummer! Just to clarify, do you have ScriptRunner for Confluence, or just ScriptRunner for JIRA? Because if you've got SR for confluence, I believe you can create a page from a template via the Java API using the CreatePageFromTemplateAction class... don't have an example handy, but I can cook one up if SR for Conf is an option for you.

Steven F Behnke
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.
December 7, 2016

I'd love to explain my use-case if you have some time, even just to share. If, of course, you talking to me? smile

Jonny Carter
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.
December 7, 2016

@Steven Behnke - sure, I'll talk. Though maybe you should open your own question with your particular details, so we don't distract from Shagufta's need?

0 votes
Najjar _Innovura_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 14, 2020

Hi Shagufta

We launched a new app that allows you to create pages from templates through Jira Workflow post-function and store the Confluence page in a Jira customfield to apply more actions like:

Workflow postfuntions

  • Update page permissions
  • Update page content
  • Update page title

Workflow conditions

  • Check if page was modified after a certain status transition
  • Check if page still has a placeholder

And so much more.

Please give it a try, I believe it would streamline alot of repeated effort on your team

Jira Confluence Workflow Extensions (JCWE) 

Give it a try I am confident you'll love it.

If you have any inquires or requests please drop me an email at admin@innovura.io

Najjar _Innovura_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 16, 2020

@Hasna 

Yes it seems very promising.

This integration guide gave us the idea of JCWE.

Why you asking?

0 votes
darrenpegg
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.
November 22, 2016

I believe if Jenkins is being used via some integration Jenkins can be used to trigger a page from template.. I don't have the details to hand. Though know it's possible..

0 votes
Steven F Behnke
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.
November 22, 2016

Confluence still hasn't exposed the Template feature to the REST API - This is probably why you don't see any documentation on this topic. 

This leaves a few options – 

  • Hardcode the HTML for the page within your groovy script
  • Copy an existing page within Confluence, within your groovy script
  • Use ScriptRunner for Confluence to expose the Template feature to REST API and then leverage it within your groovy script

 

Shagufta Gurmukhdas November 22, 2016

Can you please give an example of how the 3rd option can be done?

artafon November 28, 2016

Hi all!

I have the same problem and so little information on this subject. Shagufta, tell me please, do you resolve your task?

Suggest an answer

Log in or Sign up to answer