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
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

22,018 views 2 7
Join discussion

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