Forums

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

Scriptrunner/Groovy script to create confluence page using a template

Krishnanand Nayak
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 16, 2020

I am currently using scriptunner to create a page in confluence during a WF post function and its works. But i am stuck with:

1) the ancestor of the page is dynamic and changes based on the Fix version. how do i get the page id of a confluence page using the title?

2) the page layout need to based on a blueprint template. So,

  1. How do i get the format of a existing template? or 
  2. How do I create a blank page using a template?

the current working code is based on : https://scriptrunner.adaptavist.com/latest/jira/interacting-with-confluence-from-jira.html

1 answer

0 votes
Roland Holban (Adaptavist)
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.
July 23, 2020

I can answer your first question.

If you know the space which the page is in, you can use:

import com.atlassian.confluence.pages.PageManager
import com.atlassian.sal.api.component.ComponentLocator

def pageManager = ComponentLocator.getComponent(PageManager)

def page = pageManager.getPage(SPACE_KEY, PAGE_TITLE)
Krishnanand Nayak
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.
July 23, 2020

getting an error the script console

image.png

ABRAR ALI October 13, 2020

Hi @Krishnanand Nayak  ,

Did you get a solution for creating a page using a Template? \

-Abrar

Suggest an answer

Log in or Sign up to answer