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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Gordon Rutherford, did you ever get solution? If not, I may be able to come up with something.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
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 (:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
Gordon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tiffany
Thanks for coming back to me and yes ignoring error seems to be fine
Cheers
Gordon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Adding @Ravi Sagar _Sparxsys_
Maybe he can shoot a tutorial on his youtube vlogs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.