How to Set automatically web link in Jira cloud that connects to corresponding issue in Github?

Originally asked by dongyo kang on 28 December 2022 (original question)


How to add automatically web link in Jira cloud that connects to corresponding issue in Github when it syncs from Github to Jira Cloud?


Comments:

Support commented on 30 December 2022

Please access Sync Panel in the General Settings, as detailed in the Sync Panel article and let us know if need further assistance.

Answer by Dhiren Notani on 04 January 2023

Hi dongyo kang ,

Can you please try the below code snippet.

Jira incoming sync

if(firstSync){
issue.projectKey = “XYZ”
issue.typeName = nodeHelper.getIssueType(replica.type?.name, issue.projectKey)?.name ?: “Task”
issue.summary = replica.summary

//include other fields that maybe mandatory for creating the Jira issue.
store(issue)
}

//write the below line outside the first sync block

httpClient.post(“/rest/api/3/issue/${issue.key}/remotelink”, “”"
{
“globalId”: “${replica.key}”,
“object”: {
“url”: “${issueUrl}”,
“title”: “${replica.key}”
}
}
}“”")

//here you can paste the other mappings

issue.summary = replica.summary
issue.description = replica.description
issue.comments = commentHelper.mergeComments(issue, replica)
issue.attachments = attachmentHelper.mergeAttachments(issue, replica)
issue.labels = replica.labels

No changes are required on the GitHub side.

Do let me know how this goes and if you have any questions!.

Thanks,

Dhiren