Answer by Francis Martens (Exalate) on 26 June 2021
tournier
Check the code fragment
def statusMap = [
// "remote status name": "local status name"
"Open" : "Open",
"Selected For Development" : "Open",
"In Progress" : "Open",
"In Review" : "Open",
"In Testing" : "Open"
]
def remoteStatusName = replica.status.name
issue.setStatus(statusMap[remoteStatusName] ?: remoteStatusName)
The remote status ‘IN TESTING’ is not in the statusMap, so the statement ‘statusMap[remoteStatusName] ?: remoteStatusName’ will resolve to ‘IN TESTING’.
Probably that status is not available in the workflow.
Either add the status, or adapt the statusmap
Comments:
tournier commented on 28 June 2021
Hi, thx for the answer.
This is precisely the case, “IN TESTING” is not in the workflow of project B. This is why I called it “non-bijective”, B does not want to know about statuses of tickets inside A workflow until it reaches a common status of both A and B projects, which is “resolved”. Before being resolved, it is only seen as “OPEN” in B’s workflow, while it goes from “Selected For Development”,“In Progress”,“In Review” to “In Testing” in A’s workflow.
We can not change B’s workflow as it is shared between several projects oj JIRA server.
When you say “adapt status map” what do you mean?
best regards
tournier commented on 28 June 2021
We tried another thing and there is no error anymore, but sync only works from B to A and not from A to B (any modification from B to A is taken into account, but status modification in A project is not seen in B project)
Here is the script in A’s exalate:
OUTGOING
replica.key = issue.key
replica.type = issue.type
replica.assignee = issue.assignee
replica.reporter = issue.reporter
replica.summary = issue.summary
replica.description = issue.description
replica.labels = issue.labels
replica.comments = issue.comments
replica.resolution = issue.resolution
if ((issue.status == “RESOLVED” )||( issue.status == ”DELIVERED”) || (issue.status ==”VALIDATED”)||( issue.status ==”CLOSED”) || (issue.status ==”REJECTED”)|| (issue.status ==”DEFERRED”))
{
replica.status = issue.status
}
replica.parentId = issue.parentId
replica.priority = issue.priority
replica.attachments = issue.attachments
replica.project = issue.project
replica.fixVersions = issue.fixVersions
replica.affectedVersions = issue.affectedVersions// add by William
replica.customFields.Severity = issue.customFields.Severity //Comment these lines out if you are interested in sending the full list of versions and components of the source project.
replica.project.versions =
replica.project.components = /*
Custom Fieldsreplica.customFields.“CF Name” = issue.customFields.“CF Name”
*/
INCOMING
if(firstSync){ issue.projectKey = “BSFM2”
// Set type name from source issue, if not found set a default
issue.typeName = nodeHelper.getIssueType(replica.typeName)?.name ?: “Task”
}
issue.summary = replica.summary
issue.description = replica.description
issue.labels = replica.labels
issue.comments = commentHelper.mergeComments(issue, replica)
issue.attachments = attachmentHelper.mergeAttachments(issue, replica)
if ((issue.status != “Selected for development” )&&( issue.status != ”In Progress”) && (issue.status !=”In Stand By”)&&( issue.status !=”In Review”) && (issue.status !=”In testing”)
{
issue.status = replica.status
}
issue.customFields.“Severity”.value = replica.customFields.“Severity”?.value
issue.customFields.“Occurrence”.value = replica.customFields.“Occurrence”?.valueissue.fixVersions = replica
.fixVersions
// ensure that all the fixVersions are available on B
.collect { v -> nodeHelper.createVersion(issue, v.name, v.description) }
// assign affected versions from JIRA A to JIRA B
issue.affectedVersions = replica
.affectedVersions
.collect { v -> nodeHelper.createVersion(issue, v.name, v.description) }
In B exalate script is basically (regarding status only, I strip off all the rest of the script):
OUTGOING
replica.status = issue.status
INCOMING
issue.status = replica.status
trig is on both sides defined for creation+update
I really don’t get why statuses are not synced from A to B and only work from B to A
tournier commented on 28 June 2021
For instance, comments are well synced in both ways, so issue is really only for statuses
Francis Martens (Exalate) commented on 04 July 2021
You have to come up with the logic to implement the bidirectional mapping.
For instance if the status on B goes to ‘In testing’, then ignore the status sync on both ends …