Jira to Github Comment Impersonation and reference Issue key

Originally asked by John Smith on 06 April 2021 (original question)


What is the best way to accomplish comment impersonation and a reference from the issue key coming from Jira into GitHub?


Answer by Ariel Aguilar on 06 April 2021

The best way or workaround to accomplish comment impersonation and a reference key coming from Jira to Git hub can be sorted by adding the following code snippet into GitHub incoming script:

import groovy.json.JsonSlurper
 
if(syncRequest.remoteSyncEventNumber == 1L){
    def remoteKey = new JsonSlurper().parseText(syncRequest.replica.payload).get(replica.key)
    issue.comments = commentHelper.addComment("Remote key is ${replica.key} ", issue.comments)
}
//Above code will help on getting a comment with reference of the issue key by adding a comment with the issue key on first sync.
issue.summary      = replica.summary
issue.description  = replica.description
issue.assignee     = nodeHelper.getUserByUsername(replica.assignee?.username)
issue.reporter     = nodeHelper.getUserByUsername(replica.reporter?.username)
issue.labels       = replica.labels
issue.comments = commentHelper.mergeComments(issue, replica,                      
                    {
                       comment ->
                       comment.body =
                          "[" + comment.author.email + "] " +
                          comment.body + "\n" 
                    }
)
//This will help to add a reference from the email/author coming from Jira on each GitHub comment.

Thanks,

Ariel


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.