Do you want to bring your most awesome Jira ideas to life? Let’s see what ScriptRunner for Jira can do for you

Trinidad Wiseman
7 min readNov 29, 2023

While Jira comes with a lot of great built-in features, sometimes teams need to make additional custom configurations for workflows, automations, fields and queries.

Let’s dive in and explore some of the key features of the Data Center version of ScriptRunner for Jira, illustrated by exciting use cases.

Advanced automations with Groovy scripts

ScriptRunner excels in its ability to handle more complex scenarios by allowing administrators to extend Jira functionality using scripts written in Groovy language.

In Jira Data Center, ScriptRunner scripts gain access to the entire Jira API that Jira exposes to developers — so basically, it’s possible to conduct “upgrade in the matrix”.

But with great power comes great responsibility, so we recommend proceeding with caution.

If your Jira administrator is new to the world of Scriptrunner’s script wonders, built-in scripts might be a good starting point.

Built-in scripts

Aimed at users with limited Groovy knowledge, built-in scripts allow you to quickly achieve your goals without having to write Groovy code from scratch.

Built-in scripts have been created for some of the most commonly run tasks in ScriptRunner. For example, built in scripts include scripts to:

  • modify the resolution field of multiple issues at once with the Bulk Fix Resolutions script;
  • copy projects;
  • copy the value of a field from one field to another in your instance with Copy Field Values;
  • clean up your instance by removing workflow functions left behind by uninstalled/disabled apps.

Script Console

When built-in scripts don’t entirely meet your requirements, head over to the Script Console, which is like a clean canvas, perfect for realizing your most remarkable Jira ideas.

✨ Use case: you seek to obtain a comprehensive overview of the total hours logged for an Epic, encompassing all associated child tasks.

From a project management perspective, it’s a fundamental need to maintain a comprehensive resource usage overview for each Epic.

There are multiple ways to fulfill this requirement; the following demonstrates using Jira Automation in conjunction with ScriptRunner.

While it’s possible to outline the automation trigger conditions directly in the script, leveraging Jira Automation’s interface might offer a more intuitive and efficient approach, especially when dealing with multiple conditions or when one is still refining their Groovy scripting skills.

Next, by incorporating ScriptRunner’s “Run a script” action, the script accesses and aggregates the time tracking field values of all child tasks associated with the Epic issue, saving the sum to a designated custom field.

This script efficiently calculates the cumulative sum of logged hours and seamlessly updates the corresponding Epic, providing you with an accurate and consolidated representation of the total logged hours for the entire Epic hierarchy.

The versatility of ScriptRunner enables the creation of virtually any custom script, capable of handling intricate calculations, managing relationships across various levels, or executing system maintenance and cleanup tasks.

Figure 1. Example of a simple ScriptRunner script to perform automatic issue creation.

✨Use case: you need an automation to copy custom field values from a parent issue to its child issues.

Typically, with Jira’s native automation, the conventional approach involves manually adding each necessary custom field to the automation rule.

In contrast, ScriptRunner simplifies this process significantly by automatically comparing the fields between the parent and child issues.

When matching fields are identified, ScriptRunner’s automation efficiently duplicates pertinent values from the parent issue to the related child issues.

This approach not only minimizes the administrative burden of specifying each field individually but also ensures that the custom field values are consistently and accurately transferred from the parent to the child issues.

Customizing Workflows

ScriptRunner offers powerful custom and built-in workflow functions — post functions, validators, and conditions.

Let’s imagine we need to introduce conditional logic to our workflow transitions. With conditions, you can make sure that a requirement is met before you can transition an issue.

You can implement conditional transitions based on different issue attributes like status, priority, or custom fields.

✨ Use case: you want to implement a conditional transition that allows issues to move from the “In Progress” status to “Review” status only if the issue has a custom field called “Review Approver” set to a specific value.

Additionally, the current user executing the transition is the same as the value in the “Review Approver” field.

In this case, ScriptRunner can be used to write a custom condition script to validate both the custom field value and the current user executing the transition.

With post functions, it’s possible to perform automated actions after an issue transitions to a new status.

✨ Use case: archive an issue when it transitions to the final statust and the resolution is set to “Duplicate”.

Archiving expired or non-relevant issues is beneficial from both the user’s and Jira’s management perspective.

While archiving can also be carried out through the Bulk change interface in the issue search, it involves additional manual effort.

Customize how fields function with Behaviours

While in Jira, field configuration allows you to set fields as required/optional or hidden/visible, there are limitations to the in-depth customization of fields.

ScriptRunner, however, incorporates an awesome feature to Jira called “Behaviours”, which offers plenty of ways to extend the standard field configuration options.

With Behaviours, you can customize how fields behave. For example:

  • make a field mandatory depending on other data entered on the issue screen;
  • make a field read-only dependent on user role or group;
  • show/hide additional fields when a particular option is selected;
  • modify field descriptions;
  • restrict which issue types are available to different categories of users.

✨ Use case: as a project manager, you want full control over which issues go into a sprint.

In this scenario, Behaviours enables you can make the Sprint field read-only for anyone except users in the Project Managers role, ensuring only project managers can add issues to sprints.

Moreover, Behaviours allow you to hide and disable screen tabs (useful if you wish to hide a bunch of fields) and create select lists with an option “Other”.

A ‘Select list’ with an ‘Other’ option can be useful when users are unable to find the appropriate option from the predefined list.

Choosing the ‘Other’ option will trigger the appearance of a free text field, preventing the loss of valuable data

Integrating with other apps and external systems

ScriptRunner offers seamless integrations with various Jira apps and external systems.

✨ Use case: automated issue assignment based on user availability.

By combining ScriptRunner with your resource tracking and management tool (like Activity Timeline or Planner by Tempo) you can take your issue management process to the next level.

Consider a critical priority bug management process. Initially, it’s beneficial to automate the assignment of issues with critical priority to a designated senior developer.

While this automation might seem sufficient in theory, it’s crucial to consider the practical scenario where the senior developer may be temporarily unavailable.

The integration facilitates monitoring of resource availability, enabling the automatic reassignment of tickets to an available developer in the absence of the primary assignee.

By integrating ScriptRunner with resource management tools, it becomes possible to optimize resource allocation and expedite the ticket resolution process, ultimately enhancing overall operational efficiency.

✨ Use case: employee data from Active Directory to Jira Assets.

For instance, integrating ScriptRunner with Office365 facilitates the seamless extraction of employee data from Microsoft Entra ID (previously Azure Active Directory), effortlessly populating Assets (previously Insight)objects and associated attributes.

Users (as objects is Assets) can have multiple attributes linked to them, including contact details, departmental information, and role-specific data.

This data stored within Assets can be efficiently harnessed to support diverse operational processes. For example, it can streamline equipment procurement in customer support projects or facilitate smooth onboarding and offboarding procedures in HR projects.”

Enhanced JQL functions

ScriptRunner amplifies Jira Query Language (JQL) by introducing a rich set of 40+ additional functions, which significantly enhance your ability to craft powerful and highly customized queries.

✨ Use case: you aim to identify all Epics that have unresolved stories.

Although Jira’s standard JQL does not directly support this task, it could still be managed by following a cumbersome workaround:

  • identify all issue types that can be included in an Epic;
  • search for these issue types in the issue search, add the Resolution field as a criteria and the condition, that Epic link is not empty;
  • add the “Epic link” field column to the query results from the search view;
  • exporting the query results in XML format;
  • open the query results in Excel and perform additional data analytics to map all Epic issues.

Most likely this approach is favorable for one-time use or when the task needs to be performed occasionally.

However, if this query is used regularly, it would be more proficient to implement ScriptRunner’s JQL function issueFunction in epicsOf(“resolution = unresolved”) that would get the query results within a few seconds.

What’s more, administrators can create custom JQL functions using Groovy without having to learn the Atlassian SDK.

Now, let’s step into the shoes of a project manager, tasked with the mission to proactively prevent scope creep, and identify potential bottlenecks.

For example, you may want to see where more work was logged than originally estimated so you can identify if there was an issue with planning the scope of the issue:

For that you could use the Time Spent and the Original Estimate fields and create a query:

You may also want to see a list of all issues on track to exceed their work estimate so you can properly allocate resources. For that, you could include Remaining Estimate in the query:

Ready to “upgrade the matrix”?

To describe ScriptRunner for Jira as succinctly as possible, I would refer to what The Jira Guy said:

The self-described “Everything” Plugin — The Jira Guy

As the above is a concentrated summary of ScriptRunner, it’s important to recognize that there is still much more to explore in terms of its capabilities and the various ways it can be effectively employed.

For those interested, the official documentation offers valuable supplementary information. The application is also available on the Atlassian Cloud platform, in which case the differences in functionality are worth to consider.

Originally published at https://blog.twn.ee.

--

--

Trinidad Wiseman

Trinidad Wiseman is an Estonian service design and digital transformation company with clients across various verticals.