I am trying to copy request participants to be watchers when I move an issue from service desk to JIRA.
I think I am close. The code below crashes on watcherManager.startWatching:
def requestParticipantList = sourceIssue.getCustomFieldValue(requestParticipantsField);
def watcherManager = ComponentAccessor.watcherManager;
def userManager = ComponentAccessor.userManager;
requestParticipantList.each {
DelegatingApplicationUser user -> log.error("requestParticipant: $user");
//log.error(user.getName());
ApplicationUser u = userManager.getUserByName(user.getName());
//ApplicationUser u = user;
log.error("u class = " + u.getClass());
log.error("issue class = " + issue.getClass());
log.error("**** added " + u.getName() + " to new issue as a watcher");
watcherManager.startWatching(u, issue);
}
The log I get is:
2018-05-15 17:45:11,787 https-jsse-nio-443-exec-54 ERROR adaley 1065x450653x1 1t1h7br 10.29.128.129 /secure/CommentAssignIssue.jspa [c.o.s.c.jira.utils.ConditionUtils] requestParticipant: jbloggs(jbloggs)
2018-05-15 17:45:11,787 https-jsse-nio-443-exec-54 ERROR adaley 1065x450653x1 1t1h7br 10.29.128.129 /secure/CommentAssignIssue.jspa [c.o.s.c.jira.utils.ConditionUtils] u class = class com.atlassian.jira.user.DelegatingApplicationUser
2018-05-15 17:45:11,787 https-jsse-nio-443-exec-54 ERROR adaley 1065x450653x1 1t1h7br 10.29.128.129 /secure/CommentAssignIssue.jspa [c.o.s.c.jira.utils.ConditionUtils] issue class = class com.atlassian.jira.issue.IssueImpl
2018-05-15 17:45:11,787 https-jsse-nio-443-exec-54 ERROR adaley 1065x450653x1 1t1h7br 10.29.128.129 /secure/CommentAssignIssue.jspa [c.o.s.c.jira.utils.ConditionUtils] **** added jbloggs to new issue as a watcher
2018-05-15 17:45:11,787 https-jsse-nio-443-exec-54 ERROR adaley 1065x450653x1 1t1h7br 10.29.128.129 /secure/CommentAssignIssue.jspa [c.o.s.jira.workflow.ScriptWorkflowFunction] *************************************************************************************
2018-05-15 17:45:11,787 https-jsse-nio-443-exec-54 ERROR adaley 1065x450653x1 1t1h7br 10.29.128.129 /secure/CommentAssignIssue.jspa [c.o.s.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: ITSS-1298, actionId: 1031, file: null
java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:210)
at com.google.common.cache.LocalCache.get(LocalCache.java:3936)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3941)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4824)
at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4830)
at com.atlassian.jira.issue.watchers.DefaultWatcherManager.isWatching(DefaultWatcherManager.java:131)
at com.atlassian.jira.issue.watchers.DefaultWatcherManager.updateWatch(DefaultWatcherManager.java:171)
at com.atlassian.jira.issue.watchers.DefaultWatcherManager.startWatching(DefaultWatcherManager.java:89)
at com.atlassian.jira.issue.watchers.DefaultWatcherManager.startWatching(DefaultWatcherManager.java:80)
at com.atlassian.jira.issue.watchers.WatcherManager$startWatching$0.call(Unknown Source)
at Script338$_run_closure2.doCall(Script338.groovy:67)
at Script338.run(Script338.groovy:59)
2018-05-15 17:45:12,676 PsmmqAsyncExecutors-job:thread-648 WARN adaley 1065x450653x1 1t1h7br 10.29.128.129 /secure/CommentAssignIssue.jspa [c.a.s.p.a.modules.ruleif.CustomerVisibleStatusChangeIfCondition] The request type you are trying to view does not exist.
Can anyone spot my mistake?