Adding notification support for the external JIRA users

13.04.2012.

Popular open-source issue tracking system JIRA due to its configuration flexibility is often used not just for software development purposes. Surprisingly, it does not have a support for notifying external, non-JIRA users when commenting an issue. This blog entry shows how to achieve external users notification support using standard notification mechanisms.

The idea is to extend the comment template with the custom HTML elements holding external users’ email addresses. When the comment is submitted, email addresses are stored by the custom AddComment action class. Finally, custom mail listener will notify external users using the email addresses stored with each comment entry.

These templates will have to be edited to extend the comment box:

• $JIRA_HOME/webapp/WEB-INF/classes/templates/jira/global.vm
This function adds „Other email“ text field below the standard Comment text field. You should add the following lines at the beginning of the file:

#macro (createCustomNotificationBar)
<ul id="custom_notification" class="property-list">
    <li class="item">
        <div class="wrap">
            <strong class="name">$textutils.htmlEncode('Other email:')</strong>
            <span id="other-val" class="value">
                <input type="text" name="other_notification" id="other_notification" value="" style="width: 100%;">
            </span>
        </div>
    </li>
</ul>
#end

• $JIRA_HOME/webapp/WEB-INF/classes/templates/jira/issue/field /comment-edit.vm
The custom notification bar function is displayed only for our project. You should add the following lines at the end of the file, just before ‘#customControlFooter’ macro call:

#if ($issue.getProjectObject().getKey() == "My project")
    #createCustomNotificationBar ()
#end

Write a custom AddComment action class. It should do everything com.atlassian.jira.web.action.issue.AddComment does + storing external users’ emails. We have done this using the PropertySet-based class, but it could also be Entity Engine persistence, or ActiveObjects.

Now edit the $JIRA_HOME/webapp/secure/views/issue/viewissue.jsp

Find the following line:

<page:param name="action"><ww:url value="'/secure/AddComment.jspa'" /></page:param>

and replace it with:

<page:param name="action"><ww:url value="'/secure/CustomAddComment.jspa'" /></page:param>

Write a custom listener, which will send emails to external users when the issue is updated. Configure JIRA support for the custom listener:

  • Create the common external user in JIRA (e.g. default-external-user)
  • Configure notification scheme to notify this user of issue changes (issue created, comment added, …)
  • Configure the project to use this notification scheme (by default it uses none)
  • Add the custom mail listener and specify the common external user name
  • Disable JIRA builtin comment action (Issue Operation Plugin -> View Issue Ops Bar Comment Link). Disabling comment action is mandatory.

Further steps could be creating custom comment tab panel to show external users’ email addresses to which the notification was sent. Also, one could extend custom_notification list dinamically using JavaScript and backend REST plugin module (based on the value of some other issue field). By combining the external notification with the capability to accept incoming responses, JIRA can be used in scenarios that require involvement of external users in the issue handling.