Best Practices and App Management
Find our reccomendations for best practices and managment within the app.
Best practices for Confluence using ScriptRunner
ScriptRunner helps you automate processes you often use to manage your Confluence instance including data, users, and spaces, which reduces manual effort and potential errors.
The following sections outline automation best practices for Confluence using ScriptRunner:
The content links you to ScriptRunner for Confluence documentation, Atlassian documentation, and the ScriptRunner for Confluence Example Scripts to give you more resources to automate your instance.
Managing data
Cleanup and consolidation
ScriptRunner for Confluence has created ways to automate clearing out old content so that your instance performance doesn't slow down and your users can find the information they're looking for.
Be alerted of old content
We have created two scripts to help you identify old content so you can decide if it needs to be archived/deleted or updated.
- Use this Example Script to add a label to pages older than a particular timespan using the Script Console or a CQL Escalation Service Job.
- Search for that label using Enhanced Search.
- Review the old pages returned by the search and act, if necessary.
- Use this job to check pages and their descendants using a CQL clause to determine if there are any inactive pages.
- Review the old content and act, if necessary.
Bulk delete pages
If you've created pages in your Confluence instance that are no longer needed, use the Delete Pages built-in script.
You can use the Example Script Remove Archived Space to remove any archived spaces that have not been updated for over a year.
Bulk update macros
Use the Update Macro built-in script to update macro parameters in bulk within your Confluence instance.
Bulk update pages in a space
The following Example Scripts are available to work with multiple pages in your space all at one time:
Delete old content
Use the Automate the Removal of Old or Inactive Content Example Scripts to regularly sweep your instance for pages that haven't been updated in a specified period of time and trash them.
To delete outdated Confluence content other than pages, use the following scripts:
Delete old attachments
Delete old comments
Delete old versions
Delete trash
There are two ways to bulk purge trash:
- Bulk Purge Trash Job: Use this job to automate a trash purge on a schedule.
- Bulk Purge Trash Built-In Script: Run this built-in script to delete all trash in specified spaces or all spaces in your Confluence instance.
Fix links
Use these scripts to fix links in your Confluence instance:
- Identify Pages with Broken Image Links: Use this Example Script to generate a report of all broken links in a space to help you identify and fix them.
- Convert Absolute Links to Confluence Links: Use this built-in script to convert links to the correct internal storage format. Links could be the wrong format depending on how they were created, which leads to broken links.
- Get Outgoing Links CQL function: Use this Example Script to get a list of all outgoing links.
Manage user content
Use the Change Content Author Built-In Script to change the original Created By author of Confluence content, like pages, blog posts, comments, and attachments. You can use this script if someone is leaving your organization, and they need to hand over pages they created and managed to another user. Or if labels are used by creator for searching and indexing.
Synchronize content
If you have one page set up that needs to be mimicked across different pages, ScriptRunner has four Example Scripts to help you synchronize different content between pages:
Content engagement
ScriptRunner for Confluence can visualize how users engage with content and help you identify popular topics.
Manage watchers
As an administrator, you can make sure your users are watching/getting alerted to certain updated content by adding them as watchers.
- Add Remove Watchers Built-In Script: Run this script to manage watchers based on what's in the script.
- Add/Remove Watchers Listener: Use this listener to manage watchers based on a Confluence event.
Review statistics
Use the Space Statistics Built-In Script to get an overview of your Confluence spaces and view the:
- Number of attachments
- Number of pages
- Number of blogs
- Number of comments
- Number of labels
- Number of likes
- Number of trashed items
- Creation date
The Space Statistics Report:
- Pages older than 1 year
- Comments older than 1 year
- Attachments older than one year
Use the Display Spaces View Report Example Script to view the Spaces View Report in the Script Console.
Data access and security
For information about security vulnerabilities, visit Vulnerabilities and Security. ScriptRunner uses a number of open-source libraries, similar to most apps on the Marketplace. This page covers how we scan for vulnerabilities and common security concerns.
Permissions and restrictions 🔒
The Manage access and permissions section on this page contains a lot of information about managing user, page, and user permissions and restrictions. Maintaining updated and accurate permissions and restrictions helps your Confluence instance remain secure.
Data Center and performance
Maintaining a healthy system reduces system downtime and leads to a good user experience with Confluence running smoothly. Using ScriptRunner for Confluence, you can review what's in your instance to determine next steps. Check out the Cleanup and consolidation section to start cleaning up your instance!
Get notifications for automations
You can use Send Custom Email for Confluence Example Script to get an email when an automation has finished running.
Similarly, you can send an email based on a Confluence event using the Send Custom Email Listener. For a list of Confluence events, visit Confluence Events and Descriptions.
Review Confluence content
There are a number of reports you can view using ScriptRunner for Confluence that give you a full picture of what your Confluence instance is running. Check these out:
- List Scheduled Jobs Built-In Scripts: Run this script to view details of all jobs on the current instance.
- View Server Log Files Built-In Scripts: Run this script to show the last lines of your instance's application log files.
- Space Statistics Built-In Script: Review the report generated by this script to get an overview of your Confluence spaces.
- Display Spaces View Report: Use this Example Script to view the Spaces View Report in the Script Console.
- Export Page as PDF Job Example Script: Use this Example Script to export one or more pages as PDF on a schedule to retain a snapshot of page content over time.
Integrations
Seamless integrations create a better user experience, make you more efficient, and limit context switching. ScriptRunner for Confluence integrates with other apps through databases and various scripts to help you automate your process.
Connect with databases
Connect with relevant databases to make your Confluence instance more useful to your organization. There are two types of database connection:
- External Database Connection: Connect to any database, such as your sales or contacts database.
- Local Database Connection: Connects to the current database your Atlassian application is using.
Adding an LDAP Resource allows you to query your LDAP servers in a similar way to database connections.
Interact with Jira
We've created a number of Example Scripts to integrate your Confluence instance with your Jira instance:
- Comment on Jira Issue for Linked Confluence Pages: Automatically comment on a Jira issue whenever the linked Confluence page gets updated.
- Confluence Macro to Show User Installed Jira Apps: Show a list of apps a user has installed on their Jira instance and the gadgets and functionality they provide.
- Create a Confluence Page for Each Subtask of an Issue: Create a corresponding page, with hierarchy in place, for each sub-task of an issue in a Confluence space linked via application links.
- Create Jira issue From Forms for Confluence Submission: Connect your forms embedded in Confluence pages so new issue is created in an associated Jira instance on every form submission.
- Create a Jira Issue When a Page or Blog Post Is Approved - Comala Document Management Integration: Create a Jira issue once a page is approved in a Confluence workflow.
- Create a Jira Project When a Confluence Space is Created: Create a project in Jira when a Confluence space is created.
Interact with other apps
Here are the different ways ScriptRunner for Confluence has made it easy to integrate your Confluence instance with other apps:
All Confluence apps
Use the Show User Installed Confluence Apps Example Script to provide a macro to show a list of apps a user has installed on their instance and which macros they provide.
Comala Document Management
Use the Create a Task for Each Page Reviewer Example Script to create tasks within Comala Document Management for each reviewer. Edit the script to specify the tasks you wish to assign and set optional due dates.
Forms for Confluence
Use the scripts outlined on this listener page to automatically create a new page when a form is submitted. For example, you could want a page created when a user submits an internal feature request or events proposal using Forms for Confluence.
Slack
Use the Slack Connection documentation to set up a connection between your Slack domain and Confluence instance. Once you have this set up, you can use Slack blocks, attachments, and files in your Confluence instance.
HAPI script
Work with application links with one simple script using HAPI!
Migration
To keep a good experience for your users, limit downtime, and reduce admin and maintenance costs, use ScriptRunner for Confluence to automate your migration process.
Visit the Migrate from ScriptRunner for Confluence Server to Cloud section of the ScriptRunner for Confluence Data Center documentation to get started.
A few more links you might find important are:
Search and indexing
ScriptRunner for Confluence enables users to quickly find relevant Confluence content through our different search features. You can use these same search features within other features to automate different processes based on those search results (for example, there's CQL search in many of our listeners).
Add indexing
Add indexing methods to your Confluence content is a great way to yield good search results using CQL Guide search:
- Page Info Macro: Add various meta data (like Modified By, Created Date, Page IDs, and many others) to your Confluence content.
Example CQL to search for meta data: title
= "Company Values" - Versions History Macro: Add version data about version history to your Confluence content.
Example CQL to search for version data:
author = admin - Work with Labels: Visit the Create and Manage Content Hierarchy section on this page to see the different ways to manage labels to your Confluence content.
Example CQL to search for meta data:
label = 2024
Search your Confluence instance
Use Enhanced Search to search your entire Confluence instance (or just parts of it) for anything you want using CQL Guide!
Use CQL
Use Confluence Query Language ( CQL Guide) to perform advanced searches. Advanced searches allow you to use structured queries to search for content in Confluence.
There are two features that allow you to save custom CQL components to use in your instance frequently:
- Custom Search Fields: Create custom search fields to add useful indexes to Confluence's search to find content that meets specific criteria to expand CQL capabilities.
Tip: This is customization for the first component of the CQL Query. For example, in the
lastUser = adminquery, this is thelastUserpart. - CQL Functions: Create custom CQL functions to create and share custom CQL functions (values) with your users in order to empower their search.
Tip: This is customization for the third component of the CQL Query. For example, in the
space = allAttachmentsquery, this is theallAttachmentspart.
CQL can be run anywhere there is a search option in Confluence. You can also run CQL searches in the Script Console by using the Perform a CQL Search in SR4C Example Script.
We've also created a macro, CQL Search Macro, that enables you to place it on a page where it executes the search and returns the results as links to pages.
Use SQL to search external databases
If you want to see SQL results from an external database, you can use the Display SQL Results from an External Database Macro Example Script. This sets up a table using a custom macro on the page where it is used.
Search a page's source
Use the XPath Search in Pages to search a page's source. This can help you identify hidden structural problems in your Confluence content.
HAPI script
Search for Pages with one simple script using HAPI!
Managing users
Manage access and permissions
As a Confluence administrator, you might need to manage other users permissions and restrictions based on regulatory standards, confidential information, or to allow for external collaboration. ScriptRunner for Confluence has created several scripts to help you automate permission and restriction management.
For information about permissions required to use each ScriptRunner feature, please visit Permissions.
Copy permissions
There are two Example Scripts that automate processes for copying permissions for different Confluence content:
- Copy Individual Users Space Permissions from one Space to Another: Copy all space permissions for individual users from one space to another within your Confluence instance.
- Copy Users from Space Permissions to a Local Group: Create a group and assign permissions to that group for users within a space that have already been assigned permissions individually.
Display user groups on a Confluence page
Use the Mugshot Gallery Macro to add names and user pictures to a page in Confluence to see everyone in a group. This can be helpful if you want a visual representation of everyone in a group that has access to a space on a page.
Impersonate users
The Switch to a Different User Built-In Script allows administrator users to temporarily assume the identity of another user. Switch User has a variety of uses, such as:
- Reproducing and troubleshooting problems specific to a user to diagnose permissions issues.
- Updating content on behalf of another user if they are unavailable.
Manage restrictions
There are several scripts we created to help you automate management of page restrictions:
- Update Page Restrictions Built-In Script: Replace the editing restrictions to all of the child pages when you select a parent page. You can select multiple pages and page trees to edit restrictions in bulk.
- Update Page Restriction Job: Schedule and manage restrictions to parent and child pages. You can automatically add or remove restrictions to entire spaces or pages and manage access for newly created spaces.
- Update Page Restrictions Listener: Add and remove restrictions to parent and child pages. You can automatically add or remove restrictions to blogs or pages based on a Confluence event.
Use the Inherit Restrictions for Pages Listener to create pages that inherit the parent page restrictions. This script offers administrators the option to specify which spaces should inherit parent page view and edit restrictions automatically.
Remove permissions
There are several Example Scripts that automate processes for removing permissions for different Confluence content:
- Remove Space Permissions for a User: Remove the space permissions of a single user from a specified space within your Confluence instance.
- Restrict Page by User Group: Limit view and edit privileges on a page only to members of a specified group.
- Remove Space Permissions for a Group on All Spaces: Remove the space permissions of a single group from every space within your Confluence instance.
- Roll Back Anonymous Space Permissions via Listener: Prevent anonymous permissions from being enabled in spaces using this listener script.
HAPI script
Run Scripts as Other Users with one simple script using HAPI!
User license management
ScriptRunner for Confluence has created a few automations to help you manage your user licenses. For general information and help, visit Licensing FAQ.
Deactivate users
We know there can be limitations with number of users, so we have created a script to help you manage old users. The Check Active User Count and Disable Oldest User Example Script monitors the amount of users on your instance and disable the oldest user once a certain number is reached.
You can use the Deactivate Inactive Users in Confluence Example Script to deactivate users based on the time since they last logged in.
Give permissions
With just a username, you can easily re-activate user accounts that have been disabled using the Enable Disabled Users Example Script.
Update user credentials
If you have a company event that requires many or all of your user email licenses to be updated, we've created the Update User Emails in Bulk Example Script to automate the process.
HAPI script
Work with Users with one simple script using HAPI!
Managing spaces
Create and manage content hierarchy
A clear structure of content enables findability within your space, and ScriptRunner for Confluence has several features and scripts to help you automate hierarchy processes.
Create templates for complex Confluence instances 🌳
The Automate the Creation of Complex Page Structures within Confluence Example Script uses a REST endpoint to create complex page structures automatically. You can use this script every time you need the same page tree structure in your instance.
Move a page
Use the Move a Page When Created Example Script as a Custom Listener to move a page once it has been created. Using this script will keep the structure, and you can make sure any pages that were created stay together.
Work with labels
Labels are an easy and effective way to categorize your Confluence content. ScriptRunner for Confluence has several ways to automate label creation and maintenance.
- Built-in scripts: Manage Labels, a Confluence Administration built-in script, is a one-stop script to add, rename, and remove labels from one or more pages.
- Jobs: Use the Manage Labels Job to schedule routine label management. You can manage labels on new pages and spaces to help your users find relevant content.
- Listener: To automate label maintenance based on a Confluence event, check out Manage Labels Listener.
- Macros: To create a macro that automatically adds labels to pages where the macro is placed, follow the steps on Add Label Macro or watch this video:
To create a macro that adds labels and generates suggested labels on a page if they are not present, check out Choose Label Macro or watch this video:
- Example Scripts: To add labels to attachments, use the instructions from the Add a Label to an Attachment on a Page Example Script.
HAPI script
Work with Labels with one simple script using HAPI!
Create and manage spaces
When your spaces are created and maintained well, it increases discovery within your space. Use ScriptRunner for Confluence features and scripts to customize, create, and maintain your spaces.
Customize pages in your space
Use the Create Page Macro to create a custom page in your space. Watch our video to see the Create Page macro in action:
Or, you can use the Markdown Macro to customize the format of the pages.
Create spaces based on a template space
If you're managing a large Confluence instance and create a lot of different spaces with the same general format, ScriptRunner can help you automate that process.
- Create a space in Confluence that you want to model the other spaces after.
Tip: Name it something like Template Space to easily identify it as a template.
- Customize the Template Space however you want.
- Use the ScriptRunner built-in script, Copy Space, to use the Template Space to create new spaces.
Delete spaces
The Remove Archived Space Example Script helps you remove unused spaces in your Confluence instance.
Maintain spaces by working with pages
Use these built-in scripts to automate simple page tasks within a space:
HAPI script
Create a Page with one simple script using HAPI!
Other documentation
The following links take you to other ScriptRunner documentation that walks you through other best practices, app management, and scripting resources.