I'm adding a new transition to a resolved task that will spawn a ticket in our QA project. Basically, I want to clone the current issue, clear the assignee, and remove all the watchers. I've customized the "Additional issue actions" script to achieve this, but I keep running into errors on clearing out the watchers. The script is:
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.watchers.IssueWatcherAccessor
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.util.UserUtil
import java.util.Locale;
ComponentManager componentManager = ComponentManager.getInstance()
def currentUser = componentManager.jiraAuthenticationContext?.user
issue.summary = 'QA: ' + sourceIssue.summary
issue.description = 'ORIGINAL ISSUE:\n' + sourceIssue.description
issue.assigneeId = ''
issue.reporterId = currentUser.name
def watcherManager = ComponentAccessor.getWatcherManager()
def userUtil = ComponentAccessor.getUserUtil()
MutableIssue missue = ComponentManager.getInstance().getIssueManager().getIssueObject(issue.getKey());
def watchers = watcherManager.getWatchers(missue,Locale.getDefault());
for (user in watchers){
watcherManager.stopWatching(user,missue);
}
I don't have access to any error logs, but script runs fine in the console (with issue.getKey() replaced with an actual issue string). The last four lines seem to be causing the headache as the transition succeeds with them removed.
Any and all help is greatly appreciated.