The Exalate team will be on holiday for the coming days - returning Jan 4
Enjoy & stay safe

Questions

 
1
0
-1

Hello,

Is there a way to access the list of all synced tickets with their IDs or links in Exalate and use that list to replace GitHub link/ ID with a Jira link/ ID?

Specifically, when there is a comment from GitHub with a link to an Issue or PR I would like to somehow replace the link with a related Jira ID (or link to the ticket in Jira).


So for example someone in GitHub adds the following comment:

"Reference to PR #8" (where #8 could be an URL like this: https://github.com/org/repo/pull/8)

Of course the link is to a repo that is Exalated with Jira.


Now, that URL would be replaced by a corresponding ticket ID (or ticket link) within the comment that will be created in Jira.

Assuming all Issues and PRs are synced between the GitHub and Jira or if there's one that is not linked it will keep the original GitHub URL.


Thank you in advance for your help!

    CommentAdd your comment...

    1 answer

    1.  
      2
      1
      0

      Hi Daniel Szewczyk



      Sorry for the delay here

      Using a regular expression, it is possible to match any reference (in the format #<number>) in a comment with the twin issue using the nodeHelper.getLocalIssueFromRemoteUrn 

      By adding the logic to the closure of the mergeComment, it is possible to process all the comments.

      The code looks like this

      issue.comments     = commentHelper.mergeComments(issue, replica, {
          
          
          comment ->
          
          // match any #<number> in the comment
          def matcher  = comment.body =~ /\#(\d+) /
          def newCommentBody = comment.body
          
          matcher.each {
            match ->
            // for each reference match - look up the number and check for the twin
            targetKey = nodeHelper.getLocalIssueFromRemoteUrn(match[1])?.key
            
            if (targetKey) {
              // if the twin is found, replace the reference.
              newCommentBody = newCommentBody.replace(match[0],targetKey)    
            }
          }
          
          comment.body = newCommentBody
          
          comment
      })



      The following video demonstrates how it works

      1. Daniel Szewczyk

        Thanks again Francis for this perfect solution!
        I just have one question regarding adding a way to filter out internal comments. Previously I used this one:

        issue.comments = commentHelper.mergeComments(issue, replica, {it.internal = false})

        But now it seems it will be more challenging.

        I would appreciate your help here.


        Thank you in advance!

        Best Regards,

        Daniel

      2. Francis Martens (iDalko)

        Just add it below the 'comment.body = ...'

        But use 'comment' instead of 'it' 

        comment.internal = false



      3. Daniel Szewczyk

        Thank you Francis! 

      CommentAdd your comment...
    You are evaluating Refined.