Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

delete macro reference with Scriprunner


I need to delete all references to a macro (in this case: tracking-info) on all pages.

Is it possible with scriptrunner to run this job that would be based on a cql and delete all occurences of the macro ?

No need to keep the content inside the body of macro. Of course, it would be appreciate ;-)


Thanks for your help.



1 answer

1 accepted

1 vote
Answer accepted

Yup! This is definitely possible with ScriptRunner.

You could setup a CQL Escalation Service job (or just use the "Run Now" to run it as a one-off). A query like

macro = tracking-info and type = page 

should find all pages with the tracking-info macro in them.

As to doing the update, I've got an example up at of bulk-updating a table, but this should be just as possible to remove macro content.

I'm not 100% sure what the tracking-macro's storage format looks like, but many macros are wrapped in an ac:structured-macro tag with an ac:name attribute. You can find those elements in the Confluence storage format with a little massaging for the name-spaced format.Something like this in the inline script blank of a CQL Esclatation Service job should remove the macro and its contents entirely.

import com.atlassian.confluence.pages.PageManager
import com.atlassian.sal.api.component.ComponentLocator
import org.jsoup.Jsoup

def pageManager = ComponentLocator.getComponent(PageManager)
hits.each { page ->
def body = page.bodyContent.body
def parsedBody = Jsoup.parse(body)
def macroBody ='ac|structured-macro').attr('ac:name', 'tracking-info')
if (!macroBody.empty) {
pageManager.saveNewVersion(page) { pageObject ->

Saving the macro's body should be possible, but is left as an exercise to the reader. :)

Also, we've got some work in the backlog to bulk update macros with less code:

Thanks Jonny for your script.


I tested it as is but it doesnt work. I have a script error when pasting it in the script inline windows. I understand the idea. So I will try to make it work.

Thanks again.,



Best of luck, Michael. One pitfall might be that this won't work via the script console -- I'm assuming you're putting it into the code blank for a CQL Escalation Service Job.

Another possible pitfall is that the storage format for the tracking-info macro looks different than my script assumes. You can read up more on that format at

If you post some sample storage format, I may be able to give you some pointers on parsing it via JSOUP.

Suggest an answer

Log in or Sign up to answer
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

94 views 0 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you