ScriptRunner is an app by Adaptavist which allows the use of Groovy scripts to automate workflows, update fields and perform other actions in Jira.
It also allows users to expand functionality of other apps using their APIs. There are a number of things you can do with Structure too. In the following pages, you will find sample scripts that can be used as is or customized to create your own tailored scripts.
ScriptRunner offers a number of options, which you can access via the ScriptRunner section on the Administration | Add-Ons page.
- Script Console - This allows a user to run a specific script once. The script can make some changes in Jira and other apps and/or provide some output in the console.
- Script Fields - These scripts run for each issue and return a result that is visible on the issue page and is available as a structure column.
- Script Listeners - This allows you to store a script that will be triggered on a specified event.
- REST Endpoints - This lets you create custom API endpoints, which allow you to access Jira information from external processes.
- Built-in Script – This contains a list of scripts that come bundled with ScriptRunner. You can not change the scripts, but you can sometimes pass parameters to them.
- Script Fragments - These scripts will allow you to interface with the UI for customizations.
- Escalation Services - This allows a user to define when an issue needs to be modified after a certain time has passed.
- Script JQL Functions - This allows custom creation of JQL-callable functions, based on scripts. It includes a number of prepackaged functions.
One-Time Run Scripts
You can create or change structures by executing a script in the Script Console. You can also set up Script Listeners, so the script is triggered and executed every time some event happens.
- Creating a New Structure Programmatically - This script will create a new, empty structure.
- Creating Generators with ScriptRunner - This script can be used to create new generators in a structure.
Updating a field (ex. label) when checking all issues against a JQL query - This script will update a field (in this case Labels) for all issues that pass a certain JQL query.
- Automatically Remove Issues Based on JQL Query - This script will remove issues that do not satisfy a certain JQL query from a specific manually-built structure.
- Show All Structure Boards and Corresponding Item Counts - This script will show you the list of structures which exist in the instance and how many items were added to them manually. The result will be shown below the console.
- Bulk Change Owners of Structures and Generators - This script will bulk change the owner of structures from one user to another, useful when one user account is being archived/removed and their structures want to be preserved.
- Show work logged per user and issue for a structure - This script will create a table with users, then for each issue that they logged work on and then shows how many hours were logged for that particular issue.
Script Field Scripts
You can also add Script Fields as columns in structures.
- Show Related Issues in a Separate Column - The script creates a field containing hyperlinks to all the issues that are linked by a specific link type.
All of these samples can be implemented as is or customized to fit your specific business needs.