Receive Push Notification for Issue Creation
If you would like to receive push notifications for new issue that are created, you have the following options:
- Receiver is selected as reporter on issue creation
- Receiver is the default assignee in Jira project
- Make receiver a watcher on issue creation
In this article we explore how you can make a user or group of users a watcher so that they receive push notifications on issue creation. Here are the steps:
- Create a post-function in your workflow for the create transition
- The post-function needs to be executed before firing the event
- Add a groovy script to the post-function that assigns watchers
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.watchers.WatcherManager
import com.atlassian.jira.user.util.UserManager
WatcherManager watcherManager = ComponentAccessor.getWatcherManager()
UserManager userManager = ComponentAccessor.getUserManager()
def watchUsers = {usernames ->
usernames.each {
watcherManager.startWatching(userManager.getUserByName((String)it), issue)
}
}
def users = ["USERNAME","USERNAME2","USERNAME3"]
watchUsers(users)