[英]linking a subtask in jira with groovy
I am working on some groovy-scripts in jira. 我正在研究jira中的一些常规脚本。 The script get´s triggered as a postfunction using the scriptrunner plugin.
使用scriptrunner插件将脚本作为后功能触发。 The code, that produces the error is this one:
产生错误的代码是这样的:
ComponentAccessor CompAcc = new ComponentAccessor()
SubTaskManager subTaskManager = CompAcc.getSubTaskManager()
...
def subTask = issueManager.createIssue(CompAcc.getJiraAuthenticationContext().getLoggedInUser(), issueObject)
subTaskManager.createSubTaskIssueLink(issue, subTask, usera)
where issue is the issue, on which the postfunction was triggered. 问题所在的位置,触发了后功能的位置。 The subtask get´s created but not linked to the calling task.
子任务已创建,但未链接到调用任务。
And this is the error: 这是错误:
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)
So what I need to know, is how I can convert com.atlassian.jira.issue.IssueImpl and com.atlassian.jira.ofbiz.IssueGenericValue to com.atlassian.jira.issue.Issue so that the linking of the subtask works again. 因此,我需要知道的是如何将com.atlassian.jira.issue.IssueImpl和com.atlassian.jira.ofbiz.IssueGenericValue转换为com.atlassian.jira.issue.Issue,以便子任务的链接再次起作用。
Thanks for any help! 谢谢你的帮助!
Method issueManager.createIssue()
is deprecated, it returns GenericValue. 不建议使用
issueManager.createIssue()
方法,它将返回GenericValue。 Use issueManager.createIssueObject()
instead, it returns Issue. 使用
issueManager.createIssueObject()
代替,它将返回Issue。
So your code should look like this: 因此,您的代码应如下所示:
def currentUser = CompAcc.getJiraAuthenticationContext().getLoggedInUser()
Issue subTask = issueManager.createIssueObject(currentUser, issueObject)
subTaskManager.createSubTaskIssueLink(issue, subTask, usera)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.