1
0
-1

Hi all


I have been trying to get a script working where we replace a mention in Jira to the displayname of the user (could also be email). However, based on the info found online (such as https://community.atlassian.com/t5/Agile-articles/How-to-sanitize-mentions-when-synchronizing-issues/ba-p/1141139, How to handle mentions with accountId in a Cloud to Server sync) I havent been able to get this to work. Maybe this info is outdated or...


Anyone has this working in a currently running script for Jira Cloud? Working examples would be highly appreciated!


Kind regards

Michiel

    CommentAdd your comment...

    2 answers

    1.  
      2
      1
      0

      I do this! My script only syncs the latest comment, but the replacement works.

      This is in outgoing on the Jira side:

      if (issue.comments.findAll { comment -> comment.author.displayName != "Exalate" }) {
          latestTime = issue.comments.findAll { comment -> comment.author.displayName != "Exalate" }.max { it.created }.created
          
          lcomment = issue.comments.find { comment -> comment.created == latestTime && comment.author.displayName != "Exalate" }
          
          def matcher  = lcomment.body =~ /\[~accountid:([\w:-]+)\]/
          def newCommentBody = lcomment.body
          matcher.each {
              target = '@' + nodeHelper.getUser(it[1])?.displayName
              newCommentBody = newCommentBody.replace(it[0],target)
          }
          lcomment.body = newCommentBody
          
          replica.latestComment = lcomment
      }
        CommentAdd your comment...
      1.  
        1
        0
        -1

        Ola Timpson Adapted your scripts to my needs and it now works. Big thanks for sharing!

        1. Ola Timpson

          Glad to hear it!

        CommentAdd your comment...