1 answer
- 210
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 thisissue.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- 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
- Francis Martens (Exalate)
Just add it below the 'comment.body = ...'
But use 'comment' instead of 'it'
comment.internal = false
- Daniel Szewczyk
Thank you Francis!
Add your comment...
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!