If your organization uses Jira Cloud and Jira on-premise concurrently, then syncing user mentions in comments between the two systems is challenging.
With Exalate, it’s possible to synchronize user mentions in comments bi-directionally, making it easier for teams to collaborate seamlessly across both Jira instances.
In this blog post, we’ll dive in and implement this use case with Exalate.
The following are the use case requirements:
There are a few challenges to address.
The real challenge is that Jira Cloud and Jira on-premise handle comments differently.
They also have different formats internally.
Both systems handle user mentions as follows:
Considering the advanced nature of the use case, it’s recommended to use integration solutions to implement it.
We have chosen Exalate.
Exalate is a fully customizable bi-directional synchronization solution. It can set up integrations for popular platforms like Jira Cloud, Jira on-premise, Azure DevOps, Zendesk, ServiceNow, Salesforce, GitHub, etc.
The scripting engine that Exalate supports makes it an ideal solution for implementing advanced use cases. It also has an intuitive visual drag-and-drop interface having pre-built sync rules and mappings.
It is the only decentralized integration solution in the market. This feature allows you to handle user mentions on both systems differently and independently without messing with each other’s sync.
Let’s see how to implement this use case with Exalate.
You must install Exalate on both platforms: Jira Cloud and Jira on-premise.
Then create a connection between them. A connection works as a secure gateway to start sending information back and forth.
You can find a lot of help online regarding this on the Exalata Academy and the Getting Started Guide.
After setting up the connection, you should configure the sync rules to control what information must be sent and received at both ends.
Then you can set up triggers to enable the automatic exchange of information.
You can reach the configuration screen by clicking the “Configure Sync” button. Or you can even click the edit button on the connection list.
The sync rules (“Rules”) tab consists of the following two sections: the Incoming sync and the Outgoing sync.
In Jira Cloud:
These syncs exist on the Jira on-premise instance as well.
Let’s see how to can handle the situation when information goes from Jira Cloud to on-premise.
replica.comments = issue.comments.collect {
comment ->
def matcher = comment.body =~ /\[~accountid:([\w:-]+)\]/
def newCommentBody = comment.body
matcher.each {
target = nodeHelper.getUser(it[0])?.email ?: "Stranger"
newCommentBody = newCommentBody.replace(it[0],target)
}
comment.body = newCommentBody
comment
}
As shown in the script, a regular expression finds the comments with user mentions in them.
We replace the user mention with the email address of the corresponding user for each comment.
To do this, we use the nodeHelper.getUser() method. So the replica sent to the on-premise instance contains the actual email address instead of the user mention.
Note: Replica in Exalate context is the payload used to transfer the required information between the two systems.
for(comment in replica.addedComments){
def newCommentBody=comment.body
def matcher = comment.body =~ /[a-zA-Z0-9+._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+/
matcher.each {
x->
if (nodeHelper.getUserByEmail(x)){
def target = "[~" + nodeHelper.getUserByEmail(x).username + "]"
newCommentBody = newCommentBody.replace(x,target)
}
else
newCommentBody = newCommentBody.replace(x,"[External user with email ${x} mentioned]")
}
comment.body= newCommentBody
}
issue.comments = commentHelper.mergeComments(issue, replica)
Once the information arrives at the on-premise instance, we perform a reverse process.
We deploy a regular expression to check whether an email address is present within the comment body.
If it is present, you can find the user account corresponding to the email address using the nodeHelper.getUserByEmail() method. Then replace the email address with the username. This operation ensures that the on-premise format of the user mention is taken care of.
If the on-premise instance does not find the user, it replaces them with a custom message. This message can also state that the user mentioned on the source side does not have an associated account in the instance.
Now we’ll consider the use case in the other direction, from Jira on-premise to Jira cloud.
The logic remains the same; only the format of what we search for changes.
replica.comments = issue.comments.collect {
comment ->
if (comment.roleLevel != "Developers"){
def matcher = comment.body =~ /\[~(\w+)\]/
def newCommentBody = comment.body
matcher.each {
target = nodeHelper.getUserByUsername(it[1])?.email ?: "Stranger"
newCommentBody = newCommentBody.replace(it[0],target)
}
comment.body = newCommentBody
comment
}
}
As shown in the script, a regular expression finds the comments with user mentions in them.
We replace the user mention with the email address of the corresponding user for each comment.
To do this, we use the nodeHelper.getUserByUsername() method.
So effectively, the comment added to the replica doesn’t contain the actual mention; but rather the email address.
for(comment in replica.addedComments){
def newCommentBody=comment.body
def matcher = comment.body =~ /[a-zA-Z0-9+._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+/
matcher.each {
x->
if (nodeHelper.getUserByEmail(x)){
def target = "[~accountid:" + nodeHelper.getUserByEmail(x).key + "]"
newCommentBody = newCommentBody.replace(x,target)
}
else
newCommentBody = newCommentBody.replace(x,"[External user with email ${x} mentioned]")
}
comment.body= newCommentBody
}
issue.comments = commentHelper.mergeComments(issue, replica)
Once the replica arrives at the Jira Cloud instance, we deploy a regular expression to check whether an email address is present within the comment body.
If it does, we use the nodeHelper.getUserByEmail() method to find the corresponding email address.
Then the email address is finally replaced by the username.
We take care to maintain the cloud format of user mentions throughout the process
If the Jira cloud instance does not find the user, it replaces them with a custom message. This message can also state that the user mentioned on the source side does not have an associated account in this instance.
Exalate provides a powerful solution for synchronizing user mentions bi-directionally between Jira Cloud and Jira on-premise.
By following the steps outlined in this use case, you can ensure that team members can communicate and collaborate seamlessly, regardless of which Jira instance they are working in.
If you want to do more than sync user mentions, book a demo with Exalate engineers and see it in action!
You are welcome to join a webinar on April 6th where I will be speaking with Industry leaders about why it's important for support and development teams to collaborate smoothly and how you can make it happen. Register here please!
Syed Majid Hassan -Exalate-
0 comments