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

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
TAGS
Community showcase
Published in Teamwork

Listening out loud: how Dave Liao works on distributed teams

The start of the COVID-19 pandemic served as a forcing function to re-evaluate the way teams worked together. In fact, many companies are re-learning how to collaborate with their teams. As some move...

122 views 4 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