Groovy スクリプト

Jira のワークフローにアセット関数を追加する



アトラシアン コミュニティをご利用ください。


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

Configuring Groovy scripts

Before you run any Groovy scripts, you have to configure how they’re used on your instance.

  1. Go to Administration  > Manage apps > Assets script configuration.
  2. 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.

  3. 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.

  4. [保存] を選択します。

Groovy スクリプトが配置されているディレクトリとサブディレクトリが、すべてのユーザーによって読み取り可能で、Jira を実行しているユーザーによって実行可能であることを確認します。次に例を示します。

=$ 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


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


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:

issue.assignee != originalIssue.assignee

The current Jira user.

To check if the reporter is the current user, use the following code:

currentUser == issue.reporter

ログ フレームワーク。次のようにして atlassian-jira.log にログを記録できます。

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

ヒントと例をお探しの場合は、Groovy スクリプトの例をご参照ください。

Last modified on Mar 16, 2023


Powered by Confluence and Scroll Viewport.