Introduction


Exalate can be used to synchronize the user mentions in Comments between Jira and Azure DevOps.


In this tutorial, we will delve into the script mode of Exalate to demonstrate how user-mentions in comments from Jira can be integrated with Azure DevOps bi-directionally so that a user can get notified if he/she gets mentioned on an issue.


However, it is important to note that the prerequisite for this integration is that the email address of the user must be identical in both the Azure DevOps and Jira Cloud instances.


This requirement establishes a reliable connection point for Exalate to match and synchronize the data effectively.


  1. ADO to JIRA Sync:


def newComment
def allComments = workItem.comments.collect {
    comment ->
def comment1=comment.body
def matcher  = comment1 =~ /(?<=data-vss-mention="version:2.0,).*?(?=\")/
matcher.each {
 x->
def userId=nodeHelper.getUser(x,"project_key")?.email
 if (userId)
{
   def matcher1  = comment =~ /<a href="#" data-vss-mention="version:2.0,${x}.*?<\/a>/
 
matcher1.each{
    y->
    comment1=comment1.replaceAll(y,"[~accountid:"+userId+"]")
  }
}
         
}
    comment.body=comment1
    comment
}
replica.comments       = nodeHelper.stripHtmlFromComments(allComments)


Here is the high level notes:

<div><a href="#" data-vss-mention="version:2.0,{user id}">@John Doe<a/> Testing mentioning</div>

[~accountid:{email id}]


for(comment in replica.addedComments){
    def newCommentBody=comment.body
    def matcher  = comment.body =~ /\[~accountid:([a-zA-Z0-9+._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)\]/
 matcher.each {
 x->
    def target = nodeHelper.getUserByEmail(x[1])?.key ?:x[1]
    newCommentBody = newCommentBody.replace(x[1],target)
}
 comment.body=  newCommentBody
}
 
def addedComments = commentHelper.mergeComments(issue, replica)


Here is the high level notes:

[~accountid:{email id}]





2. JIRA to ADO Sync:


String start1="#exalate_comment#"
String end1="#exalate_comment_end#"
replica.comments = issue.comments.collect {
comment ->
      
    def matcher  = comment.body =~ /\[~accountid:([\w:-]+)\]/
    def newCommentBody = comment.body
      
    matcher.each {
     target = nodeHelper.getUser(it[1])?.email ?: "Stranger"         
     target = start1+target+end1
     newCommentBody = newCommentBody.replace(it[0],target)
    }
  
    comment.body = newCommentBody
    comment
}


Here is the high level notes:

#exalate_comment#{Email_id}#exalate_comment_end#


String start1="#exalate_comment#"
String end1="#exalate_comment_end#"
for(comment in replica.addedComments)
{
  def matcher  = comment.body =~ /(?<=#exalate_comment#).*?(?=#exalate_comment_end#)/
 
 matcher.each {
 x->
   def userId=nodeHelper.getUserByEmail(x,"Project_key")?.key
   if(userId){
     def string = "<a href=\"#\" data-vss-mention=\"version:2.0,"+userId+"\"></a>"
     def test = comment.body.replaceAll(start1+ x + end1,string)
     comment.body = test
   }    
 }
}
workItem.comments     = commentHelper.mergeComments(workItem, replica)


Here is the high level notes:

#exalate_comment#{Email_id}#exalate_comment_end#

<div><a href="#" data-vss-mention="version:2.0,{user id}">@John Doe<a/> Testing mentioning</div>


Note: Comment or remove script which is already there for comment


Video : 


Questions