-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdestinationIncomingScript
128 lines (104 loc) · 4.88 KB
/
destinationIncomingScript
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
if (firstSync) {
issue.projectKey = "PARLER"
// 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 ?: "Task"
}
issue.summary = replica.summary
issue.description = replica.description
issue.comments = commentHelper.mergeComments(issue, replica)
issue.attachments = attachmentHelper.mergeAttachments(issue, replica)
issue.labels = replica.labels
//This tell the destination side to update the Work order / priority custom field with the data from the source custom field Work Order.
issue."Work order / priority" = replica."Work Order"
def customField = issue.customFields.'TicketType'
if (customField.value?.value != "Work Item") {
customField.value = nodeHelper.getOption(issue, '10129', 'Works Item');
}
//commenting this out because it is handled later in the code
//issue.assignee = nodeHelper.getUser(replica.assignee.key)
//get priority from source
def defaultPriority = nodeHelper.getPriority("Medium")
issue.priority = nodeHelper.getPriority(replica.priority?.name) ?: defaultPriority
//map status from source
def statusMap = [
"DEV READY" : "To Do",
"Reopened" : "To Do",
"In Progress" : "In Progress",
"Ready for QA" : "Ready for QA",
"UAT" : "UAT",
"Done" : "Done",
"CLOSED/NO WORK" : "Done",
"ON HOLD" : "ON HOLD",
]
def remoteStatusName = replica.status.name
issue.setStatus(statusMap[remoteStatusName] ?: remoteStatusName)
if(replica.assignee?.key) {
issue.assignee = nodeHelper.getUser(replica.assignee.key)
} else {
issue.assignee = nodeHelper.getUser("unassigned")
}
issue.reporter = nodeHelper.getUser(replica.reporter.key)
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" )
}
}
// allows for issue that is unassigned to stay unassigned - circumventing null error
// getting null error so trying different script from the ai at exalate
/*
if(issue.assignee = null) {
replica.assignee = nodeHelper.getUser("unassigned")
} else {
issue.assignee = nodeHelper.getUser(replica.assignee.key)
}
issue.reporter = nodeHelper.getUser(replica.reporter.key)
*/
/* commenting out because this is defined in the Source Outgoing Sync
/*
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("[email protected]")
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