Only send notifications when issue is in an active Sprint


You only want to send out notifications for issues that are in an active software project sprint.

Event Selector and Filter Script

The following velocity can be added to the Event Selector and Filter script setting in both the JIRA and Non-JIRA Notification sections of a project mapping in the Event Listener.

The script will inhibit all notifications if an issue is not in an active sprint or has no sprint assigned to it:

#if ( $!customFieldManager.getCustomFieldObject("customfield_10005") ) #set($cf = $customFieldManager.getCustomFieldObject("customfield_10005")) #if ( $!issue.getCustomFieldValue($cf) ) #foreach ( $item in $issue.getCustomFieldValue($cf)) its active: $item.isActive() #set ( $isSprintActive = $item.isActive() ) #end #if ( $isSprintActive ) Issue is in current sprint #else $result.setIgnoreEvent(true) $result.setReason("Sprint is not active") #end #else Custom Field Empty - Issue has no sprint $result.setIgnoreEvent(true) $result.setReason("No Sprint has been assigned to the issue") #end #else CustomField Not Found - Issue is JSD/Business not Software #end

You will need to replace the 10005 with the ID of your Sprint custom field which can be found by navigating to JIRA Administration > Issues > Custom fields, after finding your field, click on the cog for that field and mouse over the edit link, the URL preview will display ID.

If you wish to send notifications if no sprint is assigned to an issue then the $result.setIgnoreEvent(true) and $result.setReason("No Sprint has been assigned to the issue") lines below the Custom Field Empty - Issue has no sprint message can be removed/commented out.