Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Create Confluence page using a template - Groovy

Gleb Kartashov
Contributor
June 12, 2020

Hi

I've read this documentation piece https://scriptrunner.adaptavist.com/latest/jira/interacting-with-confluence-from-jira.html

Sadly it doesn't mention using Confluence Page templates. Is it possible to create a templated page from Groovy?

3 answers

0 votes
SJ
Contributor
February 11, 2022

I'm facing a similar issue.  Within scriptrunner using this as my source

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

I would like to use a template instead of having to create the source within the script as some folks have suggested.

The one other solution I did find requires me to create a REST endpoint and the complexity is way overboard.

We're trying to modify this block to call and save a template
def params = [
type : "page",
title: pageTitle,
space: [
key: "TEST" // set the space key - or calculate it from the project or something
],
/* // if you want to specify create the page under another, do it like this:
ancestors: [
[
type: "page",
id: "14123220",
]
],*/
body : [
storage: [
value : pageBody,
representation: "wiki"
],
],
]

0 votes
Najjar _Innovura_
Atlassian Partner
June 14, 2020

Hi Gleb 

We launched a new app that allows you to create pages from templates 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 

0 votes
Ivan Tovbin
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.
June 13, 2020

Hi,

You'll need to use Confluence REST API to do it.

  1. Locate an example page with the template applied.
  2. Scrub that page via a REST API call using the following endpoint: GET /rest/api/content (This will allow you to get the storage format).
  3. From this, pass the storage format to your create call using this endpoint: POST /rest/api/content

While these steps are simplified, this process should allow you to create a page based off a user template.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events