Originally asked by Ethan Kim on 15 July 2022 (original question)
My organization uses Exalate in script mode to sync Jira and Azure DevOps. Assignee is not synced between them but we want it so when an issue or work item is assigned locally we want a comment to be made in the remote instance with the name of the assignee. For instance, if a work item was assigned in DevOps we want a comment to be made in Jira saying “DevOps Assignee: John Smith”. We have tried using the addComment function in the incoming and outgoing sync but haven’t had any success. How might we approach implementing this into our sync?
Comments:
Ariel Aguilar commented on 04 August 2022
Hi Ethan,
You can try to do:
Azure DevOps Outgoing Sync:
replica.assignee = workItem.assignee
Jira Cloud Incoming Sync:
if (replica.assignee) {
//If previous assignee is different in comparison to current assigned and not Unassigned.
if (!replica.assignee.equals(previous?.assignee) && previous?.assignee != null) {
//Construct String for comment.
String message = "Assignee for Work item: ${replica.key} has been updated from '${previous?.assignee?.displayName}' to '${replica?.assignee?.displayName}'"
//Use false property to avoid sync back.
issue.comments = commentHelper.addComment(message, false, issue.comments)
} else {
//If Unassigned is changed to Assignee.
String message = "Assignee for Work item: ${replica.key} has been updated from 'Unassigned' to '${replica?.assignee?.displayName}'"
issue.comments = commentHelper.addComment(message, false, issue.comments)
}
}
//If previous assignee is changed to Unassigned
if(replica.assignee == null) {
if (!replica.assignee.equals(previous?.assignee)) {
String message = "Assignee for Work item: ${replica.key} has been updated from '${previous?.assignee?.displayName}' to 'Unassigned'"
issue.comments = commentHelper.addComment(message, false, issue.comments)
}
}
Jira Cloud Outgoing Sync:
replica.assignee = issue.assignee
Azure DevOps Incoming Sync:
if (replica.assignee) {
if (!replica.assignee.equals(previous?.assignee) && previous?.assignee != null) {
String message = "Assignee for Jira Issue: ${replica.key} has been updated from '${previous?.assignee?.displayName}' to '${replica?.assignee?.displayName}'"
workItem.comments = commentHelper.addComment(message, false, workItem.comments)
} else {
String message = "Assignee for Jira Issue: ${replica.key} has been updated from 'Unassigned' to '${replica?.assignee?.displayName}'"
workItem.comments = commentHelper.addComment(message, false, workItem.comments)
}
}
if(replica.assignee == null) {
if (!replica.assignee.equals(previous?.assignee)) {
String message = "Assignee for Jira Issue: ${replica.key} has been updated from '${previous?.assignee?.displayName}' to 'Unassigned'"
workItem.comments = commentHelper.addComment(message, false, workItem.comments)
}
}
This should be good, just let me know.
Kind regards,
Ariel