简体   繁体   中英

How to set assignee with Jira Script Runner?

I want to set the Assignee based on Reporter. I wrote a script for that but doesn't work.

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)
}

When run, I get the following error:

error: startup failed: Script6.groovy: 12: unable to resolve class CustomField @ line 12, column 13. CustomField srcField = ComponentManager.getInstance().getCustomFieldManager().getCustomFieldObjectByName("Reporter") ^ 1 error

您缺少导入:

import com.atlassian.jira.issue.fields.CustomField
cfwt = issue.getCustomFieldValue(sccField)

sccField - here
CustomField srcField
srcField - here

You use this script as post-function?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM