将jira中的子任务与groovy

时间:2016-01-11 10:53:14

标签: groovy jira

我正在研究jira中的一些groovy脚本。脚本get使用scriptrunner插件作为postfunction触发。 产生错误的代码是这样的:

ComponentAccessor CompAcc = new ComponentAccessor()
SubTaskManager subTaskManager = CompAcc.getSubTaskManager()
...
def subTask = issueManager.createIssue(CompAcc.getJiraAuthenticationContext().getLoggedInUser(), issueObject)
subTaskManager.createSubTaskIssueLink(issue, subTask, usera)

问题是触发后期功能的问题。 子任务get已创建但未链接到调用任务。

这就是错误:

2016-01-11 11:39:39,925 http-bio-8063-exec-19 ERROR asu 699x3972x1 16m4yz4 10.1.21.129 /secure/CommentAssignIssue.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] *************************************************************************************
2016-01-11 11:39:39,926 http-bio-8063-exec-19 ERROR asu 699x3972x1 16m4yz4 10.1.21.129 /secure/CommentAssignIssue.jspa [scriptrunner.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: RQA-7338, actionId: 81, file: /home/qa/Tools/Jira/scripts/CreateDevTestExecutionSubtask.groovy
groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.config.DefaultSubTaskManager.createSubTaskIssueLink() is applicable for argument types: (com.atlassian.jira.issue.IssueImpl, com.atlassian.jira.ofbiz.IssueGenericValue, com.atlassian.jira.user.DelegatingApplicationUser) values: [RQA-7338, [timespent:null, timeoriginalestimate:7200, project:11400, ...], ...]
Possible solutions: createSubTaskIssueLink(com.atlassian.jira.issue.Issue, com.atlassian.jira.issue.Issue, com.atlassian.crowd.embedded.api.User), createSubTaskIssueLink(org.ofbiz.core.entity.GenericValue, org.ofbiz.core.entity.GenericValue, com.atlassian.crowd.embedded.api.User)
            at CreateDevTestExecutionSubtask.run(CreateDevTestExecutionSubtask.groovy:212)

所以我需要知道的是,我如何将 com.atlassian.jira.issue.IssueImpl com.atlassian.jira.ofbiz.IssueGenericValue 转换为< em> com.atlassian.jira.issue.Issue 以便子任务的链接再次起作用。

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

不推荐使用方法issueManager.createIssue(),它返回GenericValue。 请改用issueManager.createIssueObject(),它会返回问题。

所以你的代码应该是这样的:

def currentUser = CompAcc.getJiraAuthenticationContext().getLoggedInUser()
Issue subTask = issueManager.createIssueObject(currentUser, issueObject)
subTaskManager.createSubTaskIssueLink(issue, subTask, usera)