Automatic notification based on Priority

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

It might be easier to set up a filter and have the users subscribe to it. This works well for escalation scenarios.

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

}

}

}

please let me know if mentioned code has helped you.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

82 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you