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?
I think you added this post function on issue creation. You should put this post function last in the list of post function. Right now I guess it works before the issue is saved to Jira.
This is a "Clone and link issue" step, which is inserted directly after the step:
3. Update change history for an issue and store the issue in the database.
The script on this step is correctly updating the issue type and priority of the clone - just not watchers.
If I add a new step to the end of the post function list, how will I be able to access the current issue and the clone from within this script? I'm not sure this can be done.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.