Configuring Groovy scripts
Before you run any Groovy scripts, you have to configure how they’re used on your instance.
- Go to Administration > Manage apps > Assets script configuration.
Decide who can use the Assets script console and select Jira administrators and Jira system administrators or Only Jira system administrators. The default setting is Only Jira system administrators.
When deciding who can access the Assets script console, keep in mind that it’s used when adding conditions, validators and post functions.
To change who can access the Assets script console, you must be logged in as a user with the Jira system administrators global permissions.
- Add the Groovy scripts that you want to run to your allowlist. Enter the filename of a script on your server and select Add script to allowlist. Repeat this action for all of the scripts you want to use.
- Select Save.
Ensure that the directory and the subdirectories where your Groovy script is located are readable by all users and executable by the user running Jira. For example:
=$ ls -al ~/Users/jira/jira-home/atlassian-jira-servicedesk-4.20.0/scripts
drwxr-x--- 3 jira staff 96 Nov 24 21:47 .
drwxr-xr-x 21 jira staff 672 Dec 1 15:48 ..
-rw-r--r-- 1 jira staff 2421 Nov 24 21:47 Move Object to Archive.groovy
When adding a Groovy script, Assets workflow functions have the following variables pre-defined, so you can use them in your scripts.
|The issue to be transitioned.
The original issue.
You can use the attributes of issues as conditions. For example, if you want something to happen if the assignee has changed, use the following code in your condition:
The current Jira user.
To check if the reporter is the current user, use the following code:
A log framework. You can log to
If you're looking for some inspiration and examples, see Groovy script examples.