Introduction

This page describes how to exchange worklogs information between two instances. 

Worklog synchronization allows syncing work logs from one JIRA instance to another JIRA instance.

Exalate will try to find work log author and change author (by email).

If you configure work log synchronization by default, a user with email "serhiy@idalko.com" logs work in a synchronized issue BLUE-1 (synced to issue RED-1).

The Exalate would attempt to find the user with email "serhiy@idalko.com" on the Destination side, and if the user is found, create a work log on behalf of that user.

You can also configure other ways to find corresponding users on the system (by full name, by username or any other arbitrary logic that you might have).

For example, we are sharing the worklogs only in one direction, from A to B:

Source side 

Add the code provided below to the Data Filter to send worklogs to the Destination side

replica.workLogs = issue.workLogs

 

Destination side

Syncing worklogs from Jira Cloud to Jira Server

According to the Atlassian changes in user privacy policy Jira Cloud user may hide the email address visibility in the Atlassian account settings.
This affects worklog synchronization since Exalate uses API to search by email. Therefore, worklogs will be synced only in case the user has set the email to be visible.

Add the code below to the Create Processor and Change Processor to add/update received worklogs  from the source side.

  • If you sync between Jira Server instances
issue.workLogs = workLogHelper.mergeWorkLogs(issue,replica)
  • If you sync from Jira Server to Jira Cloud

final def userMapping = [
       “admin@admin.com” : “557058:ada77a72-56a9-4a19-9c23-7d66e4813883"
]
issue.workLogs = workLogHelper.mergeWorkLogs(issue,replica, { w ->
   w.author = nodeHelper.getUser(userMapping[w.author?.email]) ?: w.author
   w.updateAuthor = nodeHelper.getUser(userMapping[w.updateAuthor?.email]) ?: w.updateAuthor
})

  • If you sync from Jira Cloud to Jira Server 

final def userMapping = [
      “512358:ada77a72-56a9-4a19-9c23-7c66ee8t3883” : “admin@admin.com”
]
issue.workLogs = workLogHelper.mergeWorkLogs(issue,replica, { w ->
  w.author = nodeHelper.getUserByEmail(userMapping[w.author?.key]) ?: w.author
  w.updateAuthor = nodeHelper.getUserByEmail(userMapping[w.updateAuthor?.key]) ?: w.updateAuthor
})

  • if you sync from Jira Cloud to Jira Cloud 

issue.workLogs = workLogHelper.mergeWorkLogs(issue,replica, { w ->
 w.author = nodeHelper.getUser(w.author?.key) ?: w.author
 w.updateAuthor = nodeHelper.getUser(w.updateAuthor?.key) ?: w.updateAuthor
})

Worklog author user mapping 

You can look up the worklog author and set the author of the worklog on the Destination side due to the mapping, configured in the Create/Change Processor.


 Ways to map a worklog author:

  • set the original worklog author if the mapped user is not found on the Destination side


//----------------------------
// IF THE MAPPED USER IS NOT FOUND, USE THE ORIGINAL(SOURCE SIDE) AUTHOR
//----------------------------
// SETTINGS
def userMapping = [
        "fooey@mycompany.com" : "barry@mycompany.net"
]
// END: SETTINGS
issue.workLogs = workLogHelper.mergeWorkLogs(issue,replica, { w ->
    w.author = nodeHelper.getUserByEmail(userMapping[w.author?.email]) ?: w.author
    w.updateAuthor = nodeHelper.getUserByEmail(userMapping[w.updateAuthor?.email]) ?: w.updateAuthor
})

  • set a default worklog author if the originally mapped user is not found on the Destination side


//-------------------------
// IF THE MAPPED USER IS NOT FOUND, USE THE DEFAULT WORKLOG AUTHOR
//-------------------------
// SETTINGS
def userMapping = [
        "fooey@mycompany.com" : "barry@mycompany.net"
]
def defaultUser = nodeHelper.getUserByEmail("bazzy@mycompany.net")
// END: SETTINGS
issue.workLogs = workLogHelper.mergeWorkLogs(issue,replica, { w ->
    w.author = nodeHelper.getUserByEmail(userMapping[w.author?.email]) ?: defaultUser
    w.updateAuthor = nodeHelper.getUserByEmail(userMapping[w.updateAuthor?.email]) ?: defaultUser
})

See also