JIRA SERVERJIRA CLOUD

Introduction

When you synchronize comments, new comments are added using

  • the proxy user as a creator on Jira Server
  • the application user on Jira Cloud

The comment will look like the following:

You can impersonate the comment so that it is created using the original comment author.

The comment object has a field Executor which can be set to any user. This is how you can impersonate synced comments.


Source side

Outgoing sync (data filter)

replica.comments = issue.comments

Destination side

You can receive a new comment from the other side and apply it in different ways.

1. Assign original comment author if exists in the local system and create a new user if not found

This option works only for Jira Server


The sequence of steps: 

    • Check if the author of the comment is known locally by doing a user lookup
    • If the author is not known to the local JIRA, create the user
    • Assign the found (or created user) as an executor


Incoming sync

issue.comments = commentHelper.mergeComments(issue, replica, {
  comment ->
  
  def authorUser = userHelper.getByEmail(comment.author.email)
  
  // set the executor, optionally create the user if the local user is not found
  comment.executor = authorUser ?: userHelper.createUser(comment.author.username, 
                                                     "changeme", //password !
                                                     comment.author.email,
                                                     comment.author.displayName
                                                   )
  comment
})

2. Assign original comment author if exists in the local system, use the proxy user if not found

This option works for Jira Server and Jira Cloud

The sequence of steps: 

    • Change the comment executor from the proxy/application user to the original comment author 
    • If the author is not known in the local JIRA, use the proxy user as an author

Incoming sync

replica.addedComments.each { it.executor = nodeHelper.getUserByEmail(it.author?.email) }
replica.changedComments.each { it.executor = nodeHelper.getUserByEmail(it.updateAuthor?.email) }
issue.comments = commentHelper.mergeComments(issue, replica, { it })

Result

Comment 1 in the picture above has been created by the proxy user, while the second comment has been impersonated.


Comment impersonation on zendesk

Destination side

Incoming sync 

replica.addedComments.each { it.executor = nodeHelper.getUser("361777654679") } // replace "361777654679" with the zendesk user id
issue.comments     += replica.addedComments


Check user fields sync for more details.

See Also