Scripting Resources
To use ScriptRunner for Confluence to its full capability, write scripts in Groovy to automate and extend your Confluence instance. Using scripts, you can enhance your Confluence content and administer your Confluence instance easily.
- Enhance your Confluence spaces, pages, and users
- Administer your Confluence instance easily
ScriptRunner makes easy things easier and allows experienced users to perform advanced tasks. You can do anything in a script that you could do in a plugin, usually without the overhead of understanding the host of software development tools and methodologies that a typical plugin developer would have to worry about.
But scripting can be challenging. This page provides information on writing, maintaining, storing, and integrating scripts.
Write scripts
Every place you write code in ScriptRunner for Confluence uses the Code Editor. The browser-based Code Editor provides code completions, inline Javadoc lookups, inline find and replace, and error line indications.
To practice scripting with the Code Editor, you can use the Script Console to run one-off ad hoc scripts and to learn and experiment with the Confluence API.
Scripting languages
In ScriptRunner for Confluence, we use the Apache Groovy language to write scripts. Apache Groovy is a dynamic language for the Java platform with a familiar syntax, and it allows for domain-specific language authoring. To learn more about Apache Groovy, visit these resources:
- Introduction to Groovy is an Adaptavist ScriptRunner for Confluence documentation page that links you with specific ScriptRunner coding question resources.
- The Apache Groovy website has in-depth documentation, blog posts, and support to help you learn and troubleshoot Groovy.
Visit Using GString Templates to learn how to write Groovy scripts with dynamically generated text in ScriptRunner for Confluence.
Maintain scripts
ScriptRunner for Confluence has features to help maintain your scripts.
General script management
Manage your .groovy script files and folders using the ScriptRunner Script Editor. Reuse and share scripts across an instance without the need for FTP services or server administrators. With the Script Editor, you can create, edit, move, save, rename, and delete .groovy script files and folders in root folders from the ScriptRunner front-end.
Clear caches
You can run the Clear Groovy Class Loader built-in script to clear caches if automated clearing fails. Classes should be reloaded whenever a script is modified, but dependent classes can fail to reload.
Store scripts
Scripts are stored in script roots, which are directories that ScriptRunner will automatically scan for scripts. The scripts you store here will be available across all of ScriptRunner. The Script Roots documenation helps you with setting them up and searching script roots.
Version Control
For large instances with multiple administrators, we recommend you establish a version control system (VCS) to maintain your ScriptRunner scripts. Maintaining scripts within a VCS records changes to individual scripts over time, allowing you to revert changes and access old script versions if needed. When troubleshooting, the VCS history may contain meta-information on why a particular change was made, when it was made, and who initiated the change.
Integrate with external systems
You can interact with external systems in different ways using ScriptRunner for Confluence. The Integrations section of this documentation provides information for integrating Atlassian products and databases in specific ways. REST Endpoints and Script Plugins give you the power to use integrations how you need them.
REST Endpoints
Use Groovy scripts to define REST Endpoints, allowing you to integrate with external systems and exchange data. An endpoint is a URL that runs a script; therefore, they allow you to create custom endpoints to suit your needs.
Script Plugins
A script plugin is an Atlassian app that bundles ScriptRunner scripts and their configurations. Script plugins can be created for the following ScriptRunner components:
Test your code
If you’re using ScriptRunner extensively to write a lot of custom code or small amounts of custom code that heavily is relied on, you’re getting into the development platform portion of the product. You can write and run tests of your code to make sure it’s functioning. Visit Test Your Code to learn how to test your scripts.
When you're writing and testing a large number of scripts, you might want to set up a dev environment. This documentation provides information about requirements, ScriptRunner samples, and configurations.
Naming Custom Components