Listeners are unique to JIRA, and a very powerful way to extend it.

JIRA has a complete event subsystem which fires events whenever anything happens inside the application. For example an ISSUE_CREATED event is fired whenever an issue is created.

A Listener is a class that implements one of the Listener interfaces. It is then called whenever events occur in JIRA. Using those events, you can then perform any action you want. For example the email sent by JIRA is driven by the MailListener.

Listeners are most useful when you want to drive or affect external systems from events which occur within JIRA.

On this page:

Listener Interfaces

JIRA has the following concrete Listeners (which extend the base JiraListener interface):

com.atlassian.jira.event.JiraListener

The base interface which all other JIRA listener interfaces extend. Covers core listener properties like uniqueness, description, parameters etc.
API doc

com.atlassian.jira.event.issue.IssueEventListener

The main listener interface in JIRA, used whenever anything happens to an issue.
API doc

com.atlassian.jira.event.user.UserEventListener

This listener is called whenever anything happens to a user within JIRA.
API doc

Example Listeners

The examples provided may be freely used and modified for use in your own environment. The source of all examples is available and should give you good overview of how simple it is to write your own listeners. Both example listeners are included with JIRA 2.1, and both implement UserEventListener and IssueEventListener.

Other examples of useful tasks that can be accomplished with listeners are:

Registering a Listener

(info) For custom-written listener classes, make sure your listener class is in the classpath where JIRA can see it — the best locations are usually the <jira-application-dir>/WEB-INF/classes or <jira-application-dir>/WEB-INF/lib subdirectories within of your JIRA Installation Directory (as JAR files).

To register a listener:

  1. Log in as a user with the 'JIRA System Administrators' global permission.
  2. Select 'Administration' > 'System' > 'Advanced' > 'Listeners' (tab) to open the 'Listeners' page.
    (tick) Keyboard shortcut: 'g' + 'g' + type 'lis'
  3. In the 'Add Listener' form at the bottom of the page, complete the following fields:
  4. Click the 'Add' button and the listener will now be added to the list of listeners above.

Editing Listener Properties

If your listener accepts parameters or properties, you can edit these by clicking the 'Edit' link associated with your listener (on the 'Listeners' page in JIRA's Administration area).

When defining your own Listener, there is a method getAcceptedParams to overload for defining the parameter names, pass as an array of String objects. The DebugParamListener class is an example of doing this.

Removing a Listener

To remove a listener, click the 'Delete' link associated with that listener (on the 'Listeners' page in JIRA's Administration area).

Custom Events

With the ability to add custom events to JIRA, the Listener must be updated to deal with the event as appropriate. This is possible by providing an implementation for the method customEvent(IssueEvent event) in the Listener. For example, the MailListener implementation passes the custom event on for notification processing. The DebugListener logs that the custom event has been fired.

See Also