When syncing an issue to another JIRA server, how can I assign the issue reporter in destination as the project default or component leader ?Source: Jira Server/Datacenter(old community)
if(firstSync){
// If it's the first sync for an issue (local issue does not exist yet)
// Set project key from source issue, if not found set a default
//issue.projectKey = nodeHelper.getProject(replica.project?.key)?.key ?: "TEST"
issue.projectKey = replica.customFields."Vendor Name"?.value?.value
// Set type name from source issue, if not found set a default
issue.typeName = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: "Task"
}
issue.summary = replica.summary
issue.description = replica.description
issue.comments = commentHelper.mergeComments(issue, replica)
issue.attachments = attachmentHelper.mergeAttachments(issue, replica)
//issue.reporter = nodeHelper.getUserByUsername(replica.assignee?.username)
issue.labels = replica.labels
def targetProject = nodeHelper.getProject(issue.projectKey)
def targetComponent = nodeHelper.getComponent(replica.project.name, targetProject)
if (!targetComponent) {
targetComponent = nodeHelper.createComponent(
issue, replica.project.name, replica.project.key, null, "PROJECT_DEFAULT"
)
}
issue.components += targetComponent
issue.customFields."Autoliv Contact"?.value = replica.assignee
issue.due = replica.due
// find the correct project, issue doesn't exist yet
def jProject = ComponentAccessor.projectManager.getProjectByCurrentKey(issue.projectKey)
// set the assignee to the project lead, or admin if lead is not set
issue.reporter = nodeHelper.getUser(jProject.lead?.key ?: "admin")
Status.receive()
I got below error:
Script error details: No such property: ComponentAccessor for class: Script337. Error line: Script337.groovy:28
Regards
Comments:
Francis Martens (Exalate) commented on 27 January 2020
Answer by Francis Martens (Exalate) on 23 January 2020
A way to do this is as follows
if(firstSync && replica.project.key == "AN"){
issue.projectKey = "HAS"
issue.typeName = "Task"
// find the correct project, issue doesn't exist yet
def jProject = ComponentAccessor.projectManager.getProjectByCurrentKey(issue.projectKey)
// set the assignee to the project lead, or admin if lead is not set
issue.assignee = nodeHelper.getUser(jProject.lead?.key ?: "admin")
}