Batch updating JQL of macros embedded in Confluence pages

Olivier Béghain
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 25, 2019

Hi,

 

I'm in a situation where I have around 300 interlinked Confluence pages in which are embedded several instance of a macros that displays the result of a JQL query (sometimes showing the number of items, sometimes the issues themselves).

 

I've to _on a regular basis_ update all of these JQL queries (used by the macros) and this is a very tedious and time-consuming exercice knowing that there are round 3000 queries.

 

So, is there a way to programmatically access the content/structure of a given Confluence page and edit/modify one of the parameters of the macro (the JQL field) and perform the update? If yes, then programmatically, I would be be able to automate such updates.

 

Any inputs are welcome to address this challenge ;-)

 

Regards

Olivier.

1 answer

0 votes
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 28, 2019

Hello Olivier and welcome to the Community!
If you’re wanting to programmatically work through multiple pages within Confluence and update the contents of the pages and macro themselves then you’re most likely wanting to use the REST API. The REST API will allow you to make multiple changes to spaces, pages, and attachments through the use of scripting. With your example, I would approach this with the following endpoints:

  1. GET the content of the page you want to update
    1. GET /wiki/rest/api/content
  2. Take the content and adjust accordingly using the Confluence Storage Format
  3. PUT the update into the page
    1. PUT /wiki/rest/api/content/{id}

Further information about using the REST API may be found at Confluence Cloud Developer | REST API.

I hope this proves helpful and you’re able to start updating your content easily.

Regards,
Stephen Sifers

Patterson Waltz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 22, 2020

Hello,

Many of our Confluence pages include Jira macros to return issue lists or issue counts. When we recently renamed components in our Jira instance, the Confluence Jira macros referencing the prior component names ceased to work, similar to what @Olivier Béghain  describes in his original request.

I am attempting to use the REST API as suggested by @Stephen Sifersbut am so far unable to return just the pages which I need to update via the /wiki/rest/api/content/search endpoint. My request is as follows:


 /wiki/rest/api/content/search?cql=macro=jira%20and%20text~%27component%20=%20Product%27&expand=space,history,version,ancestors,body.storage

where my CQL query is intended to return pages which include the Jira macro and whose body in Confluence Storage Format contains the text "component = Product" which I expect to find in the macro's JQL query string contents.

This approach is not working, and I'm wondering if it's a syntax problem or rather a limitation of Lucene and/or CQL, which may not be able to search based on "invisible" text such as the macro's JQL query string.

Any further guidance would be most appreciated.

Regards,

Patterson

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events