-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsourceIncomingScript
91 lines (80 loc) · 3.95 KB
/
sourceIncomingScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
if (firstSync) {
issue.projectKey = "PAR"
// Set the same issue type as the source issue. If not found, set a default.
issue.typeName = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: "Initiative"
}
issue.summary = replica.summary
issue.description = replica.description
issue.comments = commentHelper.mergeComments(issue, replica)
issue.attachments = attachmentHelper.mergeAttachments(issue, replica)
issue.labels = replica.labels
issue.assignee = replica.assignee
//This allows the custom field Work Order in the Source to be updated with the information from custom field Work order / priority from the destination.
issue."Work Order" = replica."Work order / priority"
if(firstSync && replica.parentId && issue.typeName != "Epic"){
def localParent = nodeHelper.getLocalIssueFromRemoteId(replica.parentId.toLong())
if(localParent){
issue.parentId = localParent.id
} else {
throw new com.exalate.api.exception.IssueTrackerException("Issue cannot be created: parent issue with remote id " + replica.parentId + " was not found. Please make sure the parent issue is synchronized before resolving this error" )
}
}
//map status from source
def statusMap = [
"To Do" : "DEV READY",
"In Progress" : "In Progress",
"Ready for QA" : "Ready for QA",
"UAT" : "UAT",
"Done" : "Done",
]
def remoteStatusName = replica.status.name
issue.setStatus(statusMap[remoteStatusName] ?: remoteStatusName)
//get priority from source
def defaultPriority = nodeHelper.getPriority("Medium")
issue.priority = nodeHelper.getPriority(replica.priority?.name) ?: defaultPriority
issue.reporter = nodeHelper.getUser(replica.reporter.key)
/*
Custom Fields (CF)
To add incoming values to a Jira custom field, follow these steps:
1/ Find the Display Name of the CF. Note: If you have multiple custom fields with the same name,
then you can sync it using the custom field ID instead of its name. Know more about the steps here:
https://docs.exalate.com/docs/how-to-synchronize-custom-fields-in-jira-cloud
2/ Check how the value is coming over from the source side, by checking the "Entity Sync Status"
of an issue in sync and then selecting the "Show Remote Replica".
3/ Add it all together like this:
issue.customFields."CF Name".value = replica.customFields."CF Name".value
*/
/*
Status Synchronization
For Status sync, we map the source status, to the destination status with a hash map.
The syntax is as follows:
def statusMap = [
"remote status name": "local status name"
]
Go to Entity Sync Status, put in the entity key, and it will show you where to find the remote replica
by clicking on Show remote replica.
def statusMap = [
"New" : “Open",
"Done” : ”Resolved”
]
def remoteStatusName = replica.status.name
issue.setStatus(statusMap[remoteStatusName] ?: remoteStatusName)
*/
/*
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 also use this approach for custom fields of the type User
def defaultUser = nodeHelper.getUserByEmail("default@exalate.com")
issue.reporter = nodeHelper.getUserByEmail(replica.reporter?.email) ?: defaultUser
issue.assignee = nodeHelper.getUserByEmail(replica.assignee?.email) ?: defaultUser
*/
/*
Comment Synchronization
Impersonate comments with the original author. The sync will work if the user already exists
in the local instance.
Note: Don’t forget to remove the original comments sync line if you are using this approach.
issue.comments = commentHelper.mergeComments(issue, replica) {
it.executor = nodeHelper.getUserByEmail(it.author?.email)
}
*/
// Exalate API Reference Documentation: https://docs.exalate.com/docs/exalate-api-reference-documentation