Skip to main content

Best practices for plugin and script development

Background

Atlassian applications can be extended via several different frameworks depending on your environments. In the case of on-premise or data center options, these typically take the place of apps or plugins. A common option customers choose is Scriptrunner for Jira. This app is essentially a “wrapper” around some of the various extension points that plugins also provide. Some aspects are even quite similar.

Summary

When implementing custom plugins or scripts, we’re in the land of custom software development. This offers a lot of flexibility, but it is important to be mindful of best practices. The largest investment to consider when creating custom software is the future maintenance. Aligning with best practices helps to keep maintenance requirements as low as possible. It creates accessible code that meets the expectations of team members, which makes changing or adding code more seamless.

Concepts

Docker containers

Atlassian applications are also available as Docker containers that can be used to set up a local dev/test environment using Docker Desktop. Setup instructions are available on the respective Docker Hub pages.

Source code

Note: Free license holders aren’t allowed to download the source files.

Jira and Confluence source code is available for Atlassian customers to download. This allows you to modify the source to develop bug fixes, customizations, or additional features to suit their needs. You can download the Jira source and Confluence source code by logging in to MyAtlassian using your account.
Best Practices for Plugin and Script Development 1

Version control

Using Git for version control helps ensure that work is not lost and makes it easier to collaborate with others. It’s very important to use a version controlled workflow for all scripts and plugins. Atlassian has excellent resources to learn Git! You can check out our tutorial microsite Learn Git- Git tutorials, workflows and commands | Atlassian Git Tutorial
Best Practices for Plugin and Script Development 2

Integrated development environment (IDE)

Using an IDE makes it a lot easier to style code in a collaborative environment, use version control, and use auto-complete. It’s highly recommended that you choose an IDE that works best for you and your team. A very popular tool is IntelliJ IDEA. This tool is used in many guides in the Atlassian ecosystem and is compatible with plugins and scripts alike. 
Best Practices for Plugin and Script Development 3

Testing

Testing your code allows you to ensure your code will continue to work after making changes to it. Protect the functionality of the most valuable portions of your code by implementing testing coverage.

Scripts

Scripts and Git

Best Practices for Plugin and Script Development 4

Many instances simply “save” scripts into the database or into workflows themselves. This is impossible to maintain over time and lacks a method to easily export the scripts.

For large instances with multiple administrators, maintenance can be reduced by using Git to maintain ScriptRunner scripts. A well written guide called Version Control is provided in the Scriptrunner documentation.

Scripting with an IDE

Using an IDE provides code suggestions to easily autocomplete scripts.

For large instances with multiple administrators, development can be expedited and maintenance reduced by using a development environment to write scripts. A great guide for this is Adaptavist's article Set Up a Dev Environment.

Testing your scripts

Code that undergoes regular changes or requires mission critical uptime during changes needs be tested. Scriptrunner includes two frameworks for testing a plugin as documented in Write/Run Tests.

Plugins

Using Git with plugin development

One of the best reasons to share your plugin is that you might attract other developers to help you with it. To make it accessible to other developers, you'll need a way to share source code. Atlassian offers free Git hosting on bitbucket.org. Get started with version control in Bitbucket

Developing plugins with an IDE

Using an IDE is highly recommended for writing plugins. The Atlassian plugin SDK as well as Git can be integrated into your IDE to accelerate any work. Configure IDEA to use the SDK.

Testing custom plugins

Atlassian and Java allow multiple ways to run unit and integration tests and there are numerous guides to implementing and supplying data to these frameworks.

Resources

Was this content helpful?

Connect, share, or get additional help

Atlassian Community