Jython to create an issue

PadmeshG February 2, 2014

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

0 votes
PadmeshG March 11, 2014

thanks Manish it helped.

0 votes
Manish Kumar February 23, 2014

Padmesh,

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

0 votes
PadmeshG February 2, 2014

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 ?

Manish Kumar February 23, 2014

Padmesh,

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

0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2014

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events