Answer by Sebastian Petruschat on 18 November 2020
In the meantime, the code has changed to this but is still not working for the fields under “//This is not working”:
OUTGOING (HP QC)
if(entityType == 'testCase') {
replica.key = testCase.key
replica.owner = testCase.owner
replica.summary = testCase.summary
replica.description = testCase.description
replica.comments = commentHelper.getSingleCommentFromCommentsArea(testCase)
replica.status = testCase.status
replica.attachments = testCase.attachments
//Test Case "user fields" sync
//replica.customFields."TS_USER_05" = testCase.customFields."TS_USER_05"
} else {
replica.key = defect.key
replica.owner = defect.owner
replica.reporter = defect.detectedBy
replica.summary = defect.summary
replica.description = defect.description
replica.comments = commentHelper.getSingleCommentFromCommentsArea(defect)
replica.status = defect.status
replica.attachments = defect.attachments
replica.severity = defect.severity
replica.created = defect.created
replica.updated = defect.updated
// These are not working.
replica.id = defect.id
replica.reference = defect.reference
replica.project = defect.project
replica.customFields."user-08" = defect.customFields."Production error" //Label: Production error / Error in production since
replica.customFields."detected-in-rel" = defect.customFields."Detected in Release / Version"
}
INCOMING (JIRA)
if(firstSync){
issue.projectKey = "INTTP"
// Set type name from source issue, if not found set a default
issue.typeName = nodeHelper.getIssueType(replica.typeName)?.name ?: "Defect"
}
issue.summary = replica.summary
//issue.description = replica.description
issue.description = replica.description?.take(32767-3) + "..."
issue.labels = replica.labels
//issue.comments = commentHelper.mergeComments(issue, replica)
issue.attachments = attachmentHelper.mergeAttachments(issue, replica)
issue.created = replica.created
issue.updated = replica.updated
issue.fixVersions = replica.fixVersions
issue.resolutionDate = replica.resolutionDate
issue.affectedVersions = replica.affectedVersions
/*
User Synchronization (Assignee/Reporter)
Set a Reporter/Assignee from the source side, if the user can't be found set a default user
You can use this approach for custom fields of type User
*/
def defaultUser = nodeHelper.getUserByEmail("admin@concordia.ch")
issue.reporter = nodeHelper.getUserByEmail(replica.reporter?.email) ?: defaultUser
issue.assignee = nodeHelper.getUserByEmail(replica.assignee?.email) ?: defaultUser
/*
Comment Synchronization
Sync comments with the original author if the user exists in the local instance
Remove original Comments sync line if you are using this approach
*/
issue.comments = commentHelper.mergeComments(issue, replica){ it.executor = nodeHelper.getUserByEmail(it.author?.email) }
/*
Status Synchronization
Sync status according to the mapping [remote issue status: local issue status]
If statuses are the same on both sides don't include them in the mapping
*/
def statusMapping = ["Closed": "Closed", "Eingeplant": "Open", "Erfasst": "Open", "Fixed": "Fixed", "Im Test": "In Progress", "In Arbeit": "In Progress", "New": "Open", "Open": "Open", "Rejected": "Cancelled"]
def remoteStatusName = replica.status.name
issue.setStatus(statusMapping[remoteStatusName] ?: remoteStatusName)
/*
Severity Synchronization
Sync severity according to the mapping [remote issue severity: local issue severity]
If severities are the same on both sides don't include them in the mapping
*/
def severityMapping = ["1-Low": "1-Ohne", "2-Medium": "2-Unwesentlich", "3-High": "3-Mittel", "4-Very High": "4-Schwer", "5-Urgent": "5-Blocker"]
def remoteSeverityName = replica.severity
issue.customFields."Severity".value = severityMapping[remoteSeverityName] ?: "1-Ohne"
//The following fields are not working, including the version synchronization
issue.customFields."Reference".value = replica.reference
issue.customFields."HP QC ID".value = replica.id
issue.customFields."Project".value = replica.project
/*
Version Synchronization
*/
def remoteVersions = replica.customFields."Detected in Release / Version"?.value
issue.customFields."Detected in Release / Version".value =
remoteVersions?.collect { v -> nodeHelper.createVersion(issue, v.name, v.description) } ?: []
def remoteVersions2 = replica.customFields."Production error"?.value
issue.customFields."Production error".value =
remoteVersions?.collect { v -> nodeHelper.createVersion(issue, v.name, v.description) } ?: []
// throw new Exception("The value is: ${replica.project}") --> wrong value is synchronized (Project custom field shows com.exalate.basic.domain.hubobject.v1.BasicHubProject@df701a86(
// throw new Exception("The value is: ${replica.id}") --> value is Null error
// throw new Exception("The value is: ${replica.reference}") --> value is Null error
// throw new Exception("The value is: ${replica.customFields."user-08"}") --> value is Null error
// throw new Exception("The value is: ${replica.customFields."detected-in-rel"}") --> value is Null error
Comments:
Juan Grases commented on 17 November 2020
Hi
Actually the detected-in-rel is synced as
replica.affectedVersions = defect.affectedVersions
Is not a custom field. Regarding the CF, could you try:
replica.customFields."user-08" = defect.customFields."Production error"
Normally using the label should work.
Best regards,
Juan
Sebastian Petruschat commented on 18 November 2020
Hi Juan Grases
Thannks for your reply. In this case the field detected-in-rel is a custom field since our customer uses it in addition to Affects version/s to indicate the exact release in which the defect has been discovered.
Unfortunately, your suggested use of the label does not yield the desired result.
Best,
Sebastian