Last active
August 29, 2015 14:22
-
-
Save mfoti/ae17d59acb2700cdd785 to your computer and use it in GitHub Desktop.
This is a working solution to add JIRA Watcher with a ScriptRunner Listener
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//put this in <jira-home>/AddJiraWatcherListener.groovy and activate through custom listener | |
Import com.atlassian.jira.event.issue.AbstractIssueEventListener | |
import com.atlassian.jira.event.issue.IssueEvent | |
import com.atlassian.jira.ComponentManager | |
import com.atlassian.jira.issue.Issue | |
class AddJiraWatcherListener extends AbstractIssueEventListener { | |
@Override | |
void workflowEvent(IssueEvent event) { | |
def componentManager = ComponentManager.getInstance() | |
def watcherManager = componentManager.getWatcherManager() | |
def userManager = componentManager.getUserUtil() | |
def watchUsers = {usernames -> | |
usernames.each { | |
def user = userManager.getUser(it) | |
watcherManager.startWatching(user, event.issue.getGenericValue()) | |
} | |
} | |
def users = ["skler", "username2", "username3"] | |
watchUsers(users) | |
//log.debug "Event: ${event.getEventTypeId()} fired for ${event.issue} and caught by ExampleListener" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment