Browse Built-In Script Functionality

You can use the Search ScriptRunner Functionality search bar to search the available built-in scripts.

Search Bar

For example, if you’re looking for a built-in script that works with restrictions you could type "Restrictions" and press Enter. Then, the list of built-in scripts is narrowed down to only those containing the word "restrictions" in their title or description.

Confluence Administration Built-In Scripts

The following sections outline built-in scripts for ScriptRunner for Confluence. To access these scripts, follow these steps:

  1. Select the Confluence Administration cog, and then select General Configuration.

  2. Select Built-In Scripts from the ScriptRunner section on the left-hand side of the screen.

Add/Remove Restrictions to Parent & Child Pages

In native Confluence without ScriptRunner, editing restrictions that are added to a parent page are not inherited to the child pages. Only view restrictions are supported because they are inherited. This means that pages need to be restricted individually for editing.

With ScriptRunner for Confluence, the Add/Remove Restrictions to Parent & Child Pages built-in script, you can add the editing restrictions to all of the child pages. It is quick and easy to select multiple page trees or individual pages to set page restrictions in bulk rather than having to do it one by one. By selecting a parent page, you’ll apply all the restrictions to that page and all of its descendants.

Follow these steps to run the built-in script:

  1. Select a Space to implement the built-in script in a certain place.

    Once you select a space, Page(s) appears.

  2. Select what page trees you want to work with by selecting the checkbox next to them.

  3. Pick a value for Permission Level.

    • No Restrictions (Allows Everyone to View and Edit)

    • Editing Restricted (Allows Everyone to View, But Only Some People Can Edit)

    • Viewing and Editing Restricted (Allows Only some People to View and Edit)

      If you select the Editing Restricted or Viewing and Editing Restricted value, two more values appear Groups and Users. Adding specific groups and users to these fields enforce the restrictions only to those groups/users.

  4. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

When you select Run, restrictions are applied to the selected page and all ancestors of this page. However, this feature does not override the Confluence permission hierarchy. If you change the permission of a page or set of pages, the restrictions of an ancestor of the page with a higher level of restrictions are observed.

Read more about page restrictions in the Confluence Page Restrictions documentation.

Example Scenario

  • The page "Banana" has a child page "Tiny Banana".

  • The "Banana" page has the restriction level of Viewing and Editing Restricted applied to a user Bob.

  • The "Tiny Banana" page has No Restrictions applied using this built-in script.

Result: The user Bob can’t view the "Tiny Banana" page because the "Tiny Banana" page has inherited the Viewing and Editing Restricted" level of "Banana."

Add/Remove Watchers

You can choose to add or remove watchers on spaces, blogs, or content selected by CQL.

  1. For Select By, enter what type of watcher you want to work with.

    Your choices are:

    • Space

    • Blog

    • CQL

  2. Based on what you select in step 1, you see one of the following:

    • Target Space - Enter the space you want to work with if you picked Space or Blog.

    • CQL Query - Enter the query you want to work with if you picked CQL.

      Select Show Examples to see provided CQL queries. If you select one, the field auto-fills with the query.

      CQL statement examples

      The hit counter to the right of the field indicates how many results are returned by the CQL query you entered.

  3. For Apply to Groups, select which groups you want to work with.

  4. For Apply to Users, select which users you want to work with.

    You can select both users and groups for each set of watchers you are working with.
  5. For Action, select if you want the groups and users to Watch or Unwatch.

  6. Select Preview to view results, or select Run to apply the change.

Users are only listed in the results if they have permission to view the selected content.

If you add a user who was already watching the content, they will not be listed in the results.

If you try to remove a watcher that was not watching the content, they are not listed in the results.

Bulk Add/Remove Labels on One or More Pages

You can add or remove labels on all pages in a page tree using Bulk Add/Remove Labels on One or More Pages. This built-in script can be used to:

  • Specify one or more page trees that require updates to labels.

  • Specify whether to add or remove labels.

  • Specify the labels to be added or removed.

Follow these steps to run the built-in script:

  1. Fill out Space to implement the built-in script in a certain place.

    Once you select a space, Page(s) appears.

  2. Select what page trees you want to work with by selecting the checkbox next to them.

  3. Select the values Add Labels or Remove Labels for Action.

  4. Enter the labels you want to work with for Label(s).

    For multiple labels, separate them with a space.

  5. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

Bulk Delete Attachments

You can delete all attachments (or all attachments within the selected time range) for a page or multiple pages using Bulk Delete Attachments. This saves time and energy when there are many attachments that need to be removed.

If the attachment has been modified, the age refers to the modified date, not the creation date.

Follow these steps to run the built-in script:

  1. Fill out Spaces to run the built-in script for a particular space.

    Once you select a space, Select One or More Page Trees appears.

  2. Select which pages you want to work with by selecting the checkbox next to them.

  3. Select the Attachment Age of items to be deleted. The Preset Filters are:

    • Older Than 6 Months

    • Older Than 1 Year

    • Older Than 2 Years

    • Created Within Last Month

    • All

    • You can also select Custom Filters by selecting one in the drop-down.

      After selecting a Custom Filter, fields appear where you choose inputs. The Custom Filter choices are:

      • Created Within the Last

      • Older Than

      • Created Between / Range

  1. Check Notifications if you want to send notifications for updates.

    If Notifications is not checked, watchers of the page do not receive an email notification that the attachments have been deleted.

  2. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear and attachments within the specified time range.

Bulk Delete Comments

You can delete all comments, including inline comments, (or all comments older than a selected number of days or between a date range) for a page or multiple pages using Bulk Delete Comments. This is useful, for example, when comments become irrelevant due to content changes.

If the comment has been modified, the age refers to the modified date, not the creation date.

Follow these steps to run the built-in script:

  1. Fill out Space to run the built-in script for a particular space.

    Once you select a space, Select one or more pages appears.

  2. Select what page trees you want to work with by selecting the checkbox next to them.

  3. Select the Comment Age of items to be deleted. The Preset Filters are:

    • Older Than 6 Months

    • Older Than 1 Year

    • Older Than 2 Years

    • Created Within Last Month

    • All

    • You can also select Custom Filters by selecting one in the drop-down.

      After selecting a Custom Filter, fields appear where you choose inputs. The Custom Filter choices are:

      • Created Within the Last

      • Older Than

      • Created Between / Range

  1. Check Notifications if you want to send notifications for updates.

    If Notifications is not checked, watchers of the page do not receive an email notification that the attachments have been deleted.

  2. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear and comments within the specified time range.

Bulk Purge Trash

You can purge all trash for one or more specific spaces or all spaces in your Confluence instance using Bulk Purge Trash.

Follow these steps to run the built-in script:

  1. Select an option for Trash to Delete.

    • All Spaces

    • Select Spaces

      If you choose Select Spaces, enter the spaces in Space(s).

  2. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

Change Content Author

You can change the author of pieces of content (such as pages, blog posts, comments, and attachments) using a CQL query and Change Content Author. The Page History and the Last Modified author of the content are saved. You can only change the original Created by author.

Follow these steps to run the built-in script:

  1. Enter a statement, like creator = username, to select content to work with for CQL Query.

    Click Show Examples to reveals more CQL examples.

  2. Select the author to work with by using their username in New Author.

  3. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

Clear Groovy Class Loader

Use Clear Groovy Caches to manually clear caches if automated clearing fails. Automation should reload classes whenever a script is modified; however, dependent classes can fail to reload.

There are no fields for this built-in script. You just have to select Run or Preview. After you run this script, expect a delay in screen refresh because classes are recompiled when clearing caches.

Example Scenario

If you have a custom class file (ClassA) in your script roots and another Groovy script imports that file, modifications to ClassA may not show up until you modify the script that imports them or clear the Groovy cache with this script.

Configuration Exporter

Use Configuration Exporter to export extension configuration information to a descriptor YAML file. The YAML file contains the information required to configure built-in extension points like:

  • Listeners

  • Hooks

  • Macros

  • UI fragments

Using the YAML file within script plugins when migrating from one instance to another allows scripts to be automatically configured. Automatic configuration of scripts saves time and ensures consistency across instances.

Follow these steps to run the built-in script:

  1. Select the items you want to generate the YAML for in Export What.

    Items with configurations automatically appear here. Multiple items can be exported to one YAML file.

    configuration-exporter

  2. When the Note field appears, add a note to each item.

    Only items with notes are shown, so make sure each item has one.

  3. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, a code snippet appears.

  4. Copy this code snippet and paste it into your scriptrunner.yaml file.

You can manually edit the code yourself to add more items, though it’s generally easier to re-generate the YAML file using the Configuration Exporter script.

For more information on using YAML files to create script plugins, see Creating a Script Plugin.

Copy Page Tree

Use Copy Page Tree to copy a tree of pages to anywhere else. To run the built-in script, you must have permission to view all the pages you are copying and permission to edit the target root page.

Follow these steps to run the built-in script:

  1. Enter a space in Source Space to select the space the page tree is copied from.

  2. Select the checkbox next to the page tree you want to work with for Source Page Tree.

  3. Enter a space in Target Space to select the page the information is copied to.

  4. Select a checkbox next to the page tree that you want the information to be copied to in Target Page.

  5. Enter the text you want at the beginning of the title in Title Prefix.

  6. Enter the text you want at the end of the title in Title Suffix.

  7. Use Title Replace to find and replace words in a title when copying.

    To copy a page within the same space, manipulate the titles with a groovy closure because titles must be unique.
  8. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

Example Scenario

When a new version of a product is released, product documentation is released with it. You can copy the entire documentation page tree, version v1.0, using Copy Page Tree. When the next version of the product is released, copy the v1.0 tree and convert v1.0 to v2.0.

Links and image links within the copied page tree automatically update to reflect any new page titles. If you have a link where "v1.0 Product Doc/Introduction" links to "v1.0 Product Doc/Getting Started", the copied page tree "Introduction" links to "v2.0 Product Doc/Getting Started."

Copy Space

You can make a complete copy of an existing space using Copy Space. The following data is copied when using this script:

  • Space description

  • Theme, including any custom content and style sheets

  • All content, including attachments, and comments

  • Space templates

  • Space permissions

Page and comment likes are not copied.

Follow these steps to run the built-in script:

  1. Enter the space that you want to copy in Source Space.

  2. Enter the key of the copied space in Target Space Key.

  3. Enter the name of the copied space in Target Space Name.

  4. Select what types of things you want to be copied:

    • Inline Comments

    • Page Comments

    • Notifications

  5. For the Notifications checkbox, choose if you want to send a notification to users when copying the space.

    Currently, Atlassian doesn???t provide a way to suppress notifications for users mentioned in a comment in Confluence. Any user mentioned in a comment gets notified whether the Notifications checkbox is checked or not if comments are copied.
  6. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

Prior to upgrading to recent versions of Confluence, you could have created links to pages in Confluence by copying and pasting the URL from the browser address bar. Even though the link works, there are some problems with that method including:

  • Loss of some features (incoming links, for example)

  • Broken links if you change the title of a page

  • Loss of functionality (changing the base URL, exporting the space to another instance without breaking links)

To avoid these problems, use Convert Absolute Links to Confluence Links to convert links to the correct internal storage format. If any page has links that are required to be updated, a new page version is created, allowing you to roll back if necessary.

Convert Absolute Links to Confluence Links handles links with anchors, but anchors are still difficult to use in Confluence because they contain the page name. If a link with an anchor does not work correctly before running this built-in script, the script will not fix it.

Your base URL must be set correctly for this to work, and the base URL must match the full URLs in the pages. If it does not, then the links do not appear as candidates for rewriting.

Follow these steps to run the built-in script:

  1. Choose one of the following:

    • Select the All Spaces checkbox if you want to run the script on all global spaces.

    • Enter the specific space you want to work with for Space.

  2. Select Run.

    You can select Preview instead of Run to view a list of pages and links that are going to be updated.

    Once you select Run, the Results of the script appear.

Confluence includes JavaScript that automatically creates links with the correct internal storage format when you copy the address, but this functionality does not work on existing content. If you have recently upgraded your Confluence instance, you should only need to run Convert Absolute Links to Confluence Links once.

Delete Page Tree

Use Delete Page Tree to move a page (or pages) and all of its children to the trash.

This built-in script works around an issue where deleting a page with child pages caused the child pages to move to the top level of the space.

Using this built-in script requires remove privileges to each page you are trying to remove. If you don’t have permission for one of the pages, then no pages are removed.

Follow these steps to run the built-in script:

  1. Fill out Space to view the contained pages.

    Once you select a space, Pages appears.

  2. Select what page trees you want to work with by selecting the checkbox next to them.

  3. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

List Scheduled Jobs

Use this built-in script to list all scheduled jobs. There are no fields for this built-in script. You just have to select Run or Preview.

Rename Labels

Use this built-in script to rename the labels for one or more specific spaces or all spaces. Follow these steps to run the built-in script:

  1. Select the Location where you want to run the script:

    • Choose All Spaces if you want to work with all global spaces.

    • Choose Select Spaces if you want to enter specific spaces to work with.

      If you choose Select Spaces, a field appears for you to enter the Space(s).

  2. Specify the label that requires renaming in Original Label Name.

  3. Specify the new label name in New Label Name.

    Uppercase characters are not allowed in label names.
  4. Check Notifications if you want to send notifications for updates.

  5. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

Rename Pages

Use this built-in script to change the titles of pages. Follow these steps to run the built-in script:

  1. Enter the space you want to work with for Space.

  2. Select the pages you want to rename in Page Tree.

  3. Enter the text you want at the beginning of the title in Title Prefix.

  4. Enter the text you want at the end of the title in Title Suffix.

  5. Use Replace Text to find and replace words in a title when renaming.

  6. Check Notifications if you want to send notifications for updates.

  7. You also use the Code Transform box to change names for pages.

    Select Show Snippets for help with common name changes, like adding version IDs.
  8. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

Space Statistics

Using Space Statistics, you can get an overview of your Confluence spaces showing data such as:

  • Number of pages

  • Number of blogs

  • Number of comments

  • Number of attachments

  • Number of likes

  • Number of labels used

  • Distinct number of users that commented

  • Creation date

To use this built-in script, follow these steps:

  1. Select the space you want to work with in Spaces.

  2. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

Switch to a Different User

You can log in as a different user to troubleshoot issues they are having, including:

  • Reproduce and troubleshoot problems specific to a user to diagnose permissions issues.

  • Make updates to content on behalf of another user if they are unavailable.

To switch back to your original user, click the Return to session as link in the Switch User banner.

switch user banner

Follow these steps to run the built-in script:

  1. Choose the user you want to impersonate in User.

  2. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

Test Runner

Do not run this built-in script in a production instance. It can result in irretrievable data loss.

Use Test Runner to run JUnit and Spock tests, for use in a development instance only. Follow these steps to run the built-in script:

  1. Enter the list of packages to scan for tests in Packages.

  2. Enter tests to run in Tests.

  3. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

View Server Log Files

Use View Server Log Files to show the last N lines of application log files. Follow these steps to run the built-in script:

  1. Select the log file to view in Log File.

    Your value options are:

    • atlassian-diagnostics.log

    • atlassian-confluence.log

    • atlassian-synchrony.log

  2. Enter the number of lines to display in Number of Lines.

  3. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

XPath Search in Pages

This is an advanced built-in script. Use XPath Search in Pages to search each page’s source using the provided XPath expression. You could use this script if you require a high degree of control over the presentation of your wiki pages, and you want to make sure everything is correct.

XPath Search in Pages is more powerful for searching for structural problems than the Confluence search, but it is slower. It is best only to run this built-in script on a single space. It takes about 1.5 seconds to search a space with 2,500 pages.

To use XPath Search in Pages, you should be reasonably familiar with the Confluence XHTML storage format, and/or be prepared to examine a page’s source with the Confluence Source Editor in order to work out what expression you need.

Follow these steps to run the built-in script:

  1. Fill out Space to view the contained pages.

    Once you select a space, Pages appears.

  2. Select what page trees you want to work with by selecting the checkbox next to them.

  3. Enter the expression in Xpath Query.

    Select Show Examples for common expressions to use with this built-in script.

  4. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

CQL Query Conditions

Enter a CQL query, which is similar to a JQL query in Jira. A programming background is not needed to perform one. A CQL query always returns content. The types of content returned by a CQL query are:

  • Pages

  • Blog posts

  • Comments

  • Attachments

The example CQL query below returns all pages in a particular space which were created by a particular user:

space = KEY AND type = page AND creator = username

More examples are given on the Expand Examples part of each script that uses CQL. To learn more about CQL and how to use it effectively, see the documentation.

Space Administration Built-In Scripts

The scripts are available in the Space Tools section. These scripts can be used in spaces where the user has space admin permission. Some functionality has been restricted to reflect the lower permission level, but they operate the same as the original scripts outlined above.

To navigate to these built-in scripts, follow these steps:

  1. Select Space Tools from the bottom left-hand corner of the screen.

  2. Select Advanced Space Functionality.

Alternatively, you can follow these steps:

  1. Open the Space Directory.

  2. Select the space where you have permission by clicking the relevant i icon.

  3. Click on Advanced Space Functionality.

To use a built-in script, click on the built-in script you want to work with.

Add/Remove Restrictions to Parent and Child Pages

In native Confluence without ScriptRunner, editing restrictions that are added to a parent page are not inherited to the child pages. Only view restrictions are supported because they are inherited. This means that pages need to be restricted individually for editing.

With ScriptRunner for Confluence, the Add/Remove Restrictions to Parent & Child Pages built-in script, you can add the editing restrictions to all of the child pages. It is quick and easy to select multiple page trees or individual pages to set page restrictions in bulk rather than having to do it one by one. By selecting a parent page, you’ll apply all the restrictions to that page and all of its descendants.

Follow these steps to run the built-in script:

  1. Select a Space to implement the built-in script in a certain place.

    Once you select a space, Page(s) appears.

  2. Select what page trees you want to work with by selecting the checkbox next to them.

  3. Pick a value for Permission Level.

    • No Restrictions (Allows Everyone to View and Edit)

    • Editing Restricted (Allows Everyone to View, But Only Some People Can Edit)

    • Viewing and Editing Restricted (Allows Only some People to View and Edit)

      If you select the Editing Restricted or Viewing and Editing Restricted value, two more values appear Groups and Users. Adding specific groups and users to these fields enforce the restrictions only to those groups/users.

  4. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

When you select Run, restrictions are applied to the selected page and all ancestors of this page. However, this feature does not override the Confluence permission hierarchy. If you change the permission of a page or set of pages, the restrictions of an ancestor of the page with a higher level of restrictions are observed.

Read more about page restrictions in the Confluence Page Restrictions documentation.

Example Scenario

  • The page "Banana" has a child page "Tiny Banana".

  • The "Banana" page has the restriction level of Viewing and Editing Restricted applied to a user Bob.

  • The "Tiny Banana" page has No Restrictions applied using this built-in script.

Result: The user Bob can’t view the "Tiny Banana" page because the "Tiny Banana" page has inherited the Viewing and Editing Restricted" level of "Banana."

Add/Remove Watchers

You can choose to add or remove watchers on spaces, blogs, or content selected by CQL.

  1. For Select By, enter what type of watcher you want to work with.

    Your choices are:

    • Space

    • Blog

    • CQL

  2. Based on what you select in step 1, you see one of the following:

    • Target Space - Enter the space you want to work with if you picked Space or Blog.

    • CQL Query - Enter the query you want to work with if you picked CQL.

      Select Show Examples to see provided CQL queries. If you select one, the field auto-fills with the query.

      CQL statement examples

      The hit counter to the right of the field indicates how many results are returned by the CQL query you entered.

  3. For Apply to Groups, select which groups you want to work with.

  4. For Apply to Users, select which users you want to work with.

    You can select both users and groups for each set of watchers you are working with.
  5. For Action, select if you want the groups and users to Watch or Unwatch.

  6. Select Preview to view results, or select Run to apply the change.

Users are only listed in the results if they have permission to view the selected content.

If you add a user who was already watching the content, they will not be listed in the results.

If you try to remove a watcher that was not watching the content, they are not listed in the results.

Bulk Add/Remove Labels on One or More Pages

You can add or remove labels on all pages in a page tree using Bulk Add/Remove Labels on One or More Pages. This built-in script can be used to:

  • Specify one or more page trees that require updates to labels.

  • Specify whether to add or remove labels.

  • Specify the labels to be added or removed.

Follow these steps to run the built-in script:

  1. Fill out Space to implement the built-in script in a certain place.

    Once you select a space, Page(s) appears.

  2. Select what page trees you want to work with by selecting the checkbox next to them.

  3. Select the values Add Labels or Remove Labels for Action.

  4. Enter the labels you want to work with for Label(s).

    For multiple labels, separate them with a space.

  5. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

Bulk Delete Attachments

You can delete all attachments (or all attachments within the selected time range) for a page or multiple pages using Bulk Delete Attachments. This saves time and energy when there are many attachments that need to be removed.

If the attachment has been modified, the age refers to the modified date, not the creation date.

Follow these steps to run the built-in script:

  1. Fill out Spaces to run the built-in script for a particular space.

    Once you select a space, Select One or More Page Trees appears.

  2. Select which pages you want to work with by selecting the checkbox next to them.

  3. Select the Attachment Age of items to be deleted. The Preset Filters are:

    • Older Than 6 Months

    • Older Than 1 Year

    • Older Than 2 Years

    • Created Within Last Month

    • All

    • You can also select Custom Filters by selecting one in the drop-down.

      After selecting a Custom Filter, fields appear where you choose inputs. The Custom Filter choices are:

      • Created Within the Last

      • Older Than

      • Created Between / Range

  1. Check Notifications if you want to send notifications for updates.

    If Notifications is not checked, watchers of the page do not receive an email notification that the attachments have been deleted.

  2. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear and attachments within the specified time range.

Bulk Delete Comments

You can delete all comments, including inline comments, (or all comments older than a selected number of days or between a date range) for a page or multiple pages using Bulk Delete Comments. This is useful, for example, when comments become irrelevant due to content changes.

If the comment has been modified, the age refers to the modified date, not the creation date.

Follow these steps to run the built-in script:

  1. Enter the Space where you want to run the script.

  2. Select what pages you want to work with for Select One or More Pages.

  3. Select the Comment Age of items to be deleted. The Preset Filters are:

    • Older Than 6 Months

    • Older Than 1 Year

    • Older Than 2 Years

    • Created Within the Last Month

    • You can also select Custom Filters by selecting one in the drop-down.

      After selecting a Custom Filter, fields appear where you choose inputs. The Custom Filter choices are:

      • Created Within the Last

      • Older Than

      • Created Between / Range

  1. Check Notifications if you want to send notifications for updates.

    If Notifications is not checked, watchers of the page do not receive an email notification that the attachments have been deleted.

  2. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear and comments within the specified time range.

Bulk Purge Trash

You can purge all trash for one or more specific spaces or all spaces in your Confluence instance using Bulk Purge Trash.

Follow these steps to run the built-in script:

  1. Select if you want to delete trash in All Spaces or Select Spaces in Trash to Delete.

    If you choose Select Spaces, enter the specific spaces in Space(s).

  2. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

Copy Page Tree

Use Copy Page Tree to copy a tree of pages to anywhere else. To run the built-in script, you must have permission to view all the pages you are copying and permission to edit the target root page.

Follow these steps to run the built-in script:

  1. Enter the page you want to copy in Source Page.

  2. Select what specific pages you want to copy in Source Page Tree.

  3. Enter a space in Target Space to select the page the information is copied to.

  4. Select specific pages you want the information to be copied to in Target Page

  5. Enter the text you want at the beginning of the title in Title Prefix.

  6. Enter the text you want at the end of the title in Title Suffix.

    • Use Title Replace to find and replace words in a title when copying.

  7. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

Example Scenario

When a new version of a product is released, product documentation is released with it. You can copy the entire documentation page tree, version v1.0, using Copy Page Tree. When the next version of the product is released, copy the v1.0 tree and convert v1.0 to v2.0.

Links and image links within the copied page tree automatically update to reflect any new page titles. If you have a link where "v1.0 Product Doc/Introduction" links to "v1.0 Product Doc/Getting Started", the copied page tree "Introduction" links to "v2.0 Product Doc/Getting Started."

Copy Space

You can make a complete copy of an existing space using Copy Space. The following data is copied when using this script:

  • Space description

  • Theme, including any custom content and style sheets

  • All content, including attachments, and comments

  • Space templates

  • Space permissions

Page and comment likes are not copied.

Follow these steps to run the built-in script:

  1. Enter the space that you want to copy in Source Space.

  2. Enter the key of the copied space in Target Space Key.

  3. Enter the name of the copied space in Target Space Name.

  4. Select what types of things you want to be copied:

    • Inline Comments

    • Page Comments

    • Notifications

      For the Notifications checkbox, choose if you want to send a notification to users when copying the space.

      Currently, Atlassian doesn???t provide a way to suppress notifications for users mentioned in a comment in Confluence. Any user mentioned in a comment gets notified whether the Notifications checkbox is checked or not if comments are copied.
  5. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

Delete Page Tree

Use Delete Page Tree to move a page (or pages) and all of its children to the trash.

This built-in script works around an issue where deleting a page with child pages caused the child pages to move to the top level of the space.

Using this built-in script requires remove privileges to each page you are trying to remove. If you don’t have permission for one of the pages, then no pages are removed.

Follow these steps to run the built-in script:

  1. Fill out Space to view the contained pages.

    Once you select a space, Pages appears.

  2. Select what page trees you want to work with by selecting the checkbox next to them.

  3. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

Rename Pages

Use this built-in script to change the titles of pages. Follow these steps to run the built-in script:

  1. Enter the space you want to work with for Space.

  2. Select specific pages to rename in Page Tree.

  3. Enter the text you want at the beginning of the title in Title Prefix.

  4. Enter the text you want at the end of the title in Title Suffix.

    • Use Replace Text to find and replace words in a title when copying.

  5. Check Notifications if you want to send notifications for updates.

    If Notifications is not checked, watchers of the page do not receive an email notification that the attachments have been deleted.

  6. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

Space Statistics

Using Space Statistics, you can get an overview of your Confluence spaces showing data such as:

  • Number of pages

  • Number of blogs

  • Number of comments

  • Number of attachments

  • Number of likes

  • Number of labels used

  • Distinct number of users that commented

  • Creation date

To use this built-in script, follow these steps:

  1. Select the space you want to work with in Spaces.

  2. Select Run.

    You can select Preview instead of Run to view changes before implementing them.

    Once you select Run, the Results of the script appear.

Have questions? Visit the Atlassian Community to connect, share, and learn with other Atlassian users and experts, including Adaptavist staff.

Ask a question about ScriptRunner for JIRA, Bitbucket Server, or Confluence.

Want to learn more? Check out courses on Adaptavist Learn, an online platform to onboard and train new users for Atlassian solutions.