Jython to create an issue

I have been using Jython script to create an issue and few sub-tasks but after upgrading from v5.0.7 to 6.1.7 get following error to create a ticket.

Error creating issue: root cause: Traceback (most recent call last): File "", line 16, in TypeError: createIssue(): 1st arg can't be coerced to com.atlassian.crowd.embedded.api.User, String

Here is my jython script

#add all required imports here

from com.atlassian.jira import ComponentManager

from com.atlassian.jira.util import ImportUtils

from com.atlassian.jira import ManagerFactory

from com.atlassian.jira import ManagerFactory

issueManager = ComponentManager.getInstance().getIssueManager()

issueFactory = ComponentManager.getInstance().getIssueFactory()

authenticationContext = ComponentManager.getInstance().getJiraAuthenticationContext()

subTaskManager = ComponentManager.getInstance().getSubTaskManager()

issueObject = issueFactory.getIssue()

issueObject.setProject(issue.getProject())

issueObject.setIssueTypeId("168")

issueObject.setParentId(issue.getId())

issueObject.setPriority(issue.getPriority())

issueObject.setSummary("create sub-task")

issueObject.setReporter(issue.getReporter())

subTask = issueManager.createIssue(authenticationContext.getUser(), issueObject)

subTaskManager.createSubTaskIssueLink(issue.getGenericValue(), subTask, authenticationContext.getUser())

ImportUtils.setIndexIssues(True)

ComponentManager.getInstance().getIndexManager().reIndex(subTask)

ImportUtils.setIndexIssues(False)

The one bold are 16 and 17 lines and not sure why am i getting this error. Any help woul appreciate ?

GPK

4 answers

JIRA changed user APIs in 5.2. You will have to upgrade your scripts. Google should help you find related information.

Bob,

Thanks for the response. Wondering how user API is related to Jython script which is native in Jira.

Can you help provide more details please ?

Padmesh,

Try replacing authenticationContext.getUser() with authenticationContext.getLoggedInUser() and your scrit should work

Padmesh,

Try replacing authenticationContext.getUser() with authenticationContext.getLoggedInUser() and your scrit should work

thanks Manish it helped.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Marketplace Apps

Tips on how to choose the best estimation method for your planning

Planning and grooming sessions all come with their own sets of rules. Team members meet to estimate stories or other work items, all according to an agreed-upon process. And with every session comes ...

71 views 0 11
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you