Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,459,330
Community Members
 
Community Events
176
Community Groups

ScriptRunner for Confluence selective bulk deletion of pages

Hi

We have recently purchased SR for Confluence and  as a non coder I am looking for a script that could help with the bulk deletion of 'selected pages' to help in housekeeping our DC instance.

The selection would be something like 'last updated more than 2 years ago' and then the ability to bulk delete that selection.

A related but side question on the selection - could SR establish a 'last page view'?

Then I could combine these two filters or run them independently before deleting the returned pages

Thanks in advance for help here!

Regards

Gordon

3 answers

3 accepted

0 votes
Answer accepted

Hi all, this script is now available in our Script Library for ScriptRunner for Confluence Server/DC (tested by our engineers).

Feel free to copy or customise it as you wish https://library.adaptavist.com/entity/automate-the-removal-of-old-or-inactive-content

Nice - thanks for update

0 votes
Answer accepted

Hey @Gordon Rutherford, did you ever get solution? If not, I may be able to come up with something.

Hi Tiffany

Not yet and I am actually getting a price from the Adaptavist Scripting service to write the code - and if it is not to expensive for my limited budget I would proceed with that. I have received a lot of helpful (free) support from your team over the last two years and would be happy to pay for it for once if price is reasonable!

If not I may be raising it out the next champions hour!

Regards

Gordon

Like Tiffany Wortham likes this

Hey Gordon!

Since I didn't get to answer this for Champion Hour, here's a solution that may work for you.

Create a CQL escalation service job that looks like this:
Screen Shot 2022-02-22 at 12.19.50 PM.png
It may seem like a strange choice, but we're using a CQL escalation service job so we can use CQL to select the right pages. I have the cron expression set so far in the future so that it won't run regularly, but if you would like it to run it regularly, of course, you could just use a different cron expression. Since we're selecting the pages through CQL, the script is really simple:

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

def pageManager = ComponentLocator.getComponent(PageManager)

hits.each { page ->
pageManager.trashPage(page, DefaultDeleteContext.DEFAULT)
}

In order to see which pages you're about to delete, you can check the hits you get next to the CQL Query field. If you see some pages you don't want to delete, just add a label to them and exclude that label in your CQL query, like "label != 'whatever'"

You can just hit "Run now" to run this once. Hope this helps (:

Like # people like this

Hi Tiffany

I really appreciate you coming back to me with this after the hour yesterday which, as always was great.

Something is not quite working as expected for me and it throws a StackOverflowError when I 'run now', however if you then run it again it works as expected and deletes the page. See my snip for the error

Thanks for your input

Best regards

Gordonstackoevrflow.PNG

Hi Gordon,

I think I remember this happening to me at one point too. I'm not sure why this happens sometimes, but I don't think it actually has anything to do with the script itself. I'd say just ignore it, and try running it again when that happens.

Hi Tiffany

Thanks for coming back to me and yes ignoring error seems to be fine

Cheers

Gordon

0 votes
Answer accepted

Adding @Ravi Sagar _Sparxsys_ 

Maybe he can shoot a tutorial on his youtube vlogs.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS

Atlassian Community Events