Skip to main content

3 min read

11 new ScriptRunner for Confluence example scripts for you to try

Illustration of three people building 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 code examples for Confluence 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.

View script

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. 

View script

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.

View script

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.

View script

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.

View script

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.

View script

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! 

View script

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.

View script

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.

View script

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!

View script

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.

View script

Take a look at our Script Library for a complete list of ScriptRunner for Confluence example scripts!

ScriptRunner for Confluence logo with purple light orbiting

Fancy a 30-day free trial of ScriptRunner?

Enjoy a 30-day free trial of ScriptRunner for Confluence. Available on Server, Data Center and cloud.

Find out more

About the authors

Jessie Wang

Jessie Wang

Jessie is the Product Marketing Manager for ScriptRunner for Confluence.