Groovy scripts

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

You can run Groovy scripts both in conditions and validators and post functions. They give you more power and flexibility, but are recommended for advanced users.

Good to know

Each Groovy script has to be whitelisted. To add Groovy scripts to the Whitelist:

  1. Go to Administration  > Manage apps > Insight Whitelist.
  2. Select Edit settings.
  3. Enter the filename and the full path to the script like in the example below:

Groovy script path example in the Whitelist

4. 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
total 8
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


Variables

When adding a Groovy script, the Insight workflow functions has the following variables pre-defined, so you can use them in your scripts.

VariableDescription
issueThe issue to be transitioned.
originalIssue

The original issue. You can check conditions, like if the assignee has changed by:

issue.assignee != originalIssue.assignee
currentUser

The current Jira user. You can check if the reporter is the current user by:

currentUser == issue.reporter
log

A log framework. You can log to atlassian-jira.log by:

log.warn("This is a warning!");


Examples

If you're looking for some inspiration and examples, see Groovy script examples.

Last modified on Apr 29, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.