Groovy script listeners

Since version 1.0.3

Script listeners allows you to add customized behaviours and actions that will be triggered by changes in Jira issues.

Add a new listener

You nedd Jira administrator privileges to be able to add or modify Script listeners

Go to Administration (cog icon) > Manage apps > WMB Listeners > Add listeners

Options

Enabled – If disabled the listener won’t be triggered by any issue change.

Listener name – Just a name for using it in the listener view.

Projects – Select one or more projects. Only issues of these projects will trigger this listener. Leave empty to listen all projects.

JQL – You can refine which issues will trigger the listener. For example “status = Open” will make that only events of issues in Open status can call this listener.

Events – Select that this listener will be listening. Leave empty to listen all events.

 

Once you have wrote your script you can save it. Also you can check the script against any issue using the options in the editor toolbar.

Scripting rules

  • Listener scripts accept groovy scripts. It doesnt expect any return code and it will be ignored if present.

  • You can user ComponentAccessor to access Managers and other useful classes.

  • You can user issue to access the current Issue.

  • You can user event to access the current Event.

  • You can user user to access the current Application user.

Example

This minimum example adds a comment to the current issue:

import com.atlassian.jira.component.ComponentAccessor; ComponentAccessor.getCommentManager().create(issue, user, "This is a sample comment", false);

 

View script listeners

Go to Administration (cog icon) > Manage apps > WMB Listeners >View listeners

A table containing all relevant info about configured scripts will be shown:

Click on a script name to enter the edit view.