Skip to main content
11 new ScriptRunner for Confluence example scripts for you to try
Share on socials
Lightning jumps out of a confluence page
An orange placeholder
Jessie Wang
12 August 2022

11 new ScriptRunner for Confluence example scripts for you to try

Example code you can modify or customise for your own needs. Do anything from bulk updating emails in Confluence, automating removal of old content, to displaying SQL results on a Confluence page.
We've released 11 new ScriptRunner example scripts for Confluence Data Center/Server into the Adaptavist Script Library.
They cover many easy wins, from bulk updating emails to displaying database information on a Confluence page.
ScriptRunner opens the doors for anything you want to do in Confluence, but it can be tricky sometimes to know where to begin, especially if you're new to the app or don't code as your day job. 
This is where the Adaptavist Script Library comes in. It's a free resource that provides a bank of ready-made Confluence examples that you can take away and modify for your own needs.
These scripts are taken from real customer use cases and are tested and verified by our engineering team. They're a great way to explore the possibilities with ScriptRunner and to familiarise yourself with the Confluence Java API.
We've outlined the 11 new scripts below; take a look for some ideas and inspiration on how you can make your Confluence admin faster and easier.

ScriptRunner for Confluence example scripts

You can modify any of the following script examples for your Confluence on-prem instance to transform it however you need.

Prevent anonymous permissions in a space

When anonymous access permissions are applied within selected spaces, this script will run and roll back the permission, giving you control over which spaces you want to allow anonymous access.

Add label to outdated pages

This confluence example script can bulk add labels to pages based on a specific age. Use it to help review and manage content to ensure it is up to date. As a Job, it can be set to run on a regular schedule. For instance, once a week, any pages older than two years can be labelled with ‘For Review’.
This can be beneficial in multiple ways. It notifies visitors to the page that the information they are looking at may be outdated, or the label can be searched to create a list of pages to consider for clean-up. 

Set limit on maximum active user count

Manage the number of active users to stay within your licence tier. When the maximum user count is reached and a new user is added, the script automatically deactivates the user with the oldest login date to maintain the same number of users on the instance.

Get all content that links to a particular page

This CQL (Confluence Query Language) Function allows you to return a list of all content that links to a particular page. Ensure important pages are appropriately linked back to by child pages or check how popular a page is in your space. You can define which space(s) you want the CQL Function to search.

Automate the removal of old or inactive content

This script helps you keep your content up to date and improves the speed of your instance. It uses the CQL Escalation Service to return a list of pages older than a specified date, and then automatically deletes them. It can be set to run on a regularly scheduled basis.

Scheduled export of Confluence page to PDF using Jobs

Automate a regular audit or snapshot to meet your reporting requirements by configuring a scheduled export of one or more Confluence pages. The pages will be exported to a PDF file and saved in your specified directory for future reference.

Display SQL results from an external database

Display external data on any Confluence page with this Custom Macro script. Pull information from an external database via an SQL query and format the selected data as a table within the macro. Keep the team informed about almost anything! 

Update user emails in bulk

This script can help you maintain your user contact information in bulk if your organisation’s domain or email address format changes. Useful for companies that have rebranded or have acquired other companies and wish to consolidate.

Identify Confluence pages with broken image links

This example script generates a list of pages with broken image links within a specified space. Fix the areas where your content is not working as it should and where key visual information is missing.

Copy users from space permissions to the local group

This script helps you apply group-based permissions where permissions have been previously granted to individual users.
The script will add individual users with common permissions settings to an appropriate group, and then apply permission settings to the whole group.
Clean up and consolidate your permissions settings in minutes rather than hours!

Add a category label to spaces in bulk

This example script allows you to bulk add labels to one or more spaces. Labelling makes searching within Confluence easier, and can also help monitor the popularity of different space types or topics within your Confluence.
Take a look at our Script Library for a complete list of ScriptRunner for Confluence example scripts!