如何使用Jira Script Runner设置受理人?

时间:2015-08-13 07:09:47

标签: groovy jira

我想根据Reporter设置受理人。我为此编写了一个脚本但不起作用。

import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.event.type.EventDispatchOption

CustomField srcField = ComponentManager.getInstance().getCustomFieldManager().getCustomFieldObjectByName("Reporter")

cfwt = issue.getCustomFieldValue(sccField)

if(cfwt == "User Name"){
  MutableIssue myIssue = issue
  IssueManager issueManager = ComponentAccessor.getIssueManager()
  UserManager userManager = ComponentAccessor.getUserManager()
  myIssue.setCustomFieldValue(reviewerCustomField, assignee)
  issueManager.updateIssue(userManager.getUser("User Name"), myIssue, EventDispatchOption.DO_NOT_DISPATCH, false)
}

运行时,我收到以下错误:

  

错误:   启动失败:Script6.groovy:12:无法解析类CustomField @第12行,第13列.CustomField srcField = ComponentManager.getInstance()。getCustomFieldManager()。getCustomFieldObjectByName(“Reporter”)^ 1 error

2 个答案:

答案 0 :(得分:0)

您缺少导入:

import com.atlassian.jira.issue.fields.CustomField

答案 1 :(得分:-1)

cfwt = issue.getCustomFieldValue(sccField)

sccField - 这里是 CustomField srcField
srcField - 这里是

您将此脚本用作后期功能吗?