I'm trying to add watchers after a Story is added in a project. I've been bouncing all over existing questions and sample scripts, but changes in JIRA versions have rendered all the examples I could find as deficient in one way or another.
Not sure where this is breaking since from what I can tell DelegatingApplicationUser is an implementation of ApplicationUser and IssueImpl is an implementation of Issue.
groovy.lang.MissingMethodException: No signature of method: static com.atlassian.jira.issue.watchers.WatcherManager.startWatching() is applicable for argument types: (com.atlassian.jira.user.DelegatingApplicationUser, com.atlassian.jira.issue.IssueImpl) values: [johndoe(johndoe), ISS-01]
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.issue.watchers.WatcherManager
def userManager = ComponentAccessor.getUserManager()
def watchUsers = {usernames ->
usernames.each {
def user = userManager.getUserByName("${it}")
WatcherManager.startWatching(user, issue)
}
}
def users = ["johndoe","janedoe"]
if(issue.getIssueType().name=="Story"){
watchUsers(users)
}