Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Community showcase
Published in Marketplace Apps & Integrations

Learn how to request and manage app requests in the Marketplace

G’day everyone! Super exciting news coming from the Marketplace. We have now fully rolled out the ability for end-users to submit app requests to admins directly from within the product! No longer ...

62 views 1 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you