2
1
0
- last knight
- Jan 23, 2020
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
- connector-onpremise-jira
- Comment
CommentAdd your comment...
4 answers
- 10-1
Thanks Francis,
I used the below code:
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
- Francis Martens (Exalate)
Ah - you need to import the class
Add in the first line
import com.atlassian.jira.component.ComponentAccessor
CommentAdd your comment... - 10-1
it is working now ... I haven't seen your last comment
- Francis Martens (Exalate)
Alright - I'm a bit lost with the different comments disguished as answer. Assuming you're all set?
CommentAdd your comment... - 10-1
sorry for late reply
I got below error:
Script error for issue TECHNIA-3. Details: No such property: jProject for class: Script47. Error line: Script47.groovy:14
I used below syntax in incoming sync in destination JIRA server:
issue.reporter = nodeHelper.getUser(jProject.lead?.key ?: "admin")
issue.assignee = nodeHelper.getUser(jProject.lead?.key ?: "admin")CommentAdd your comment... - 10-1
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") }
Is this clear?
CommentAdd your comment...
Overview
Content Tools
search
attachments
weblink
advanced