Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,362,507
Community Members
 
Community Events
168
Community Groups

Clone project not working on issue transition, but works with script console

Edited

I have a script which reads some custom fields to get the required information to clone a project.

Then I have the following code to clone the project (only relevant parts are shown):

// Bot user has admin access
// src, tar, and name is read from custom field as String
def copyProject = new CopyProject();
def user = ComponentAccessor.getUserManager().getUserByName("bot");
def inputs = [
(CopyProject.FIELD_SOURCE_PROJECT) : src,
(CopyProject.FIELD_TARGET_PROJECT) : tar,
(CopyProject.FIELD_TARGET_PROJECT_NAME) : name,
(CopyProject.FIELD_COPY_ISSUES) : true,
(CopyProject.FIELD_COPY_VERSIONS) : true,
(CopyProject.FIELD_COPY_COMPONENTS) : true,
]

ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(user);
copyProject.doScript(inputs);

When I run this script using the script console, I get no errors and the cloning works perfectly.

However I added my script to a workflow transition and every time the transition occurs my script fails.

Here is the error log that I can see:

java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:877)
at com.google.common.cache.LocalCache.get(LocalCache.java:3951)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3974)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4958)
at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4964)
at com.atlassian.jira.issue.watchers.DefaultWatcherManager.isWatching(DefaultWatcherManager.java:134)
at com.atlassian.jira.issue.watchers.DefaultWatcherManager.updateWatch(DefaultWatcherManager.java:174)
at com.atlassian.jira.issue.watchers.DefaultWatcherManager.startWatching(DefaultWatcherManager.java:92)
at com.atlassian.jira.issue.watchers.DefaultWatcherManager.startWatching(DefaultWatcherManager.java:83)
at com.atlassian.jira.issue.watchers.WatcherManager$startWatching$0.call(Unknown Source)
at com.onresolve.scriptrunner.canned.jira.utils.AbstractCloneIssue$_copyWatchers_closure7.doCall(AbstractCloneIssue.groovy:413)
at com.onresolve.scriptrunner.canned.jira.utils.AbstractCloneIssue.copyWatchers(AbstractCloneIssue.groovy:412)
at com.onresolve.scriptrunner.canned.jira.utils.AbstractCloneIssue.execute(AbstractCloneIssue.groovy:249)
at com.onresolve.scriptrunner.canned.jira.utils.CopyIssueWithAttachments.super$4$execute(CopyIssueWithAttachments.groovy)
at com.onresolve.scriptrunner.canned.jira.utils.CopyIssueWithAttachments.execute(CopyIssueWithAttachments.groovy:25)
at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CloneIssue.super$5$execute(CloneIssue.groovy)
at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CloneIssue.execute(CloneIssue.groovy:135)
at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.CloneIssue$execute.call(Unknown Source)
at com.onresolve.scriptrunner.canned.jira.admin.CopyProject$_doCopyProject_closure13.doCall(CopyProject.groovy:601)
at com.onresolve.scriptrunner.canned.jira.admin.CopyProject.doCopyProject(CopyProject.groovy:580)
at com.onresolve.scriptrunner.canned.jira.admin.CopyProject$doCopyProject.callCurrent(Unknown Source)
at com.onresolve.scriptrunner.canned.jira.admin.CopyProject.execute(CopyProject.groovy:357)
at com.onresolve.scriptrunner.canned.jira.admin.CopyProject.execute(CopyProject.groovy)
at com.onresolve.scriptrunner.canned.AbstractCannedScript.doScript(AbstractCannedScript.groovy:81)
at com.onresolve.scriptrunner.canned.CannedScript$doScript$13.call(Unknown Source)
at add_project.run(add_project.groovy:94)

 
Can anyone suggest why I could be getting this error?

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events