Automatic notification based on Priority

John Lao April 14, 2014
Is it possible for JIRA to send notification to a group of users or add a group of users to the watchers list if an issue has been created with a certain priority?

3 answers

0 votes
Paresh Gandhi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 15, 2014

please let me know if mentioned code has helped you.

0 votes
Paresh Gandhi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 15, 2014

Yes, you can develop groovy scirpt. Sample is below. This has to go on issue create and generic event to make it work under script listener of add-on

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.event.issue.AbstractIssueEventListener

import com.atlassian.jira.event.issue.IssueEvent

import com.atlassian.jira.issue.Issue

import org.apache.log4j.Logger

import com.atlassian.jira.ComponentManager

import static org.apache.log4j.Level.DEBUG

class TaskListener extends AbstractIssueEventListener {

Logger log = Logger.getLogger(TaskListener.class)

def groupManager = ComponentAccessor.getGroupManager()

def watcherManager = ComponentAccessor.getWatcherManager()

def userManager = ComponentAccessor.getUserManager()

@Override

void workflowEvent(IssueEvent event) {

Issue issue = event.getIssue();

log.setLevel(DEBUG)

log.debug "Event: ${event.getEventTypeId()} fired for ${issue} and caught by TaskVersionListener"

def priority = issue.getPriorityObject().getName()

log.debug priority

def issuestatus = issue.getStatusObject().getName().toUpperCase()

log.debug "status of issue" + issuestatus

def criticalUser = userManager.getUserObject("user1")

def seriousUser = userManager.getUserObject("user2")

switch (priority) {

case 'Critical':

if (!issuestatus.equals("xxx")){

watcherManager.startWatching(criticalUser, issue.genericValue)

watcherManager.stopWatching(seriousUser, issue.genericValue)

}

break

case 'Serious':

if (!issuestatus.equals("xxx")){

watcherManager.startWatching(seriousUser, issue.genericValue)

watcherManager.stopWatching(criticalUser, issue.genericValue)

}

break

case 'Important':

watcherManager.stopWatching(criticalUser, issue.genericValue)

watcherManager.stopWatching(seriousUser, issue.genericValue)

break

case 'Minor':

watcherManager.stopWatching(criticalUser, issue.genericValue)

watcherManager.stopWatching(seriousUser, issue.genericValue)

break

}

}

}

0 votes
Jason Plumhoff
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 14, 2014
It might be easier to set up a filter and have the users subscribe to it. This works well for escalation scenarios.

Suggest an answer

Log in or Sign up to answer