Multiple Configuration Scenarios: Jira to Github

Originally asked by Jillani Fazal on 05 May 2023 (original question)


I already checked on these docs and tried. but it didn’t work. Can you please provide me the code snippet to use in incoming and outgoing sync by checking our current mentioned above? Please note that we are trying to move issues from JIRA to GitHub

1. Sync assignees

https://docs.exalate.com/docs/how-to-sync-assignees-on-github : This document is for GH to GH sync. However, we have added the assignee parameter in our code above and tried but it didn’t work. please check the code snippets in the above mail

2. Sync Jira ticket status and map to GH statuses (closed or opened) if possible
https://docs.exalate.com/docs/search?phrase=status&Search= : We couldn’t find a proper answer in these docs, we already checked on the docs. can you please pinpoint the exact code snippet?

3. Sync Jira releases (fixVersion) to Gihub milestones or labels:
https://docs.exalate.com/docs/search?phrase=milestones&Search= : These articles show how to synchronize milestones from GitHub issues to Jira only. we want the code snippets for the opposite way around, however we tried the code snippets given here as well but didn’t work. Please check the code snippets in the above mail
Sync links between Jira issue and Jira release (fix version) - not needed. this is same as the above “Sync Jira releases (fix version) to Gihub milestones or labels:”

4. Sync links between Jira issues and PRs
we want to move the PR links under the development attribute in JIRA to GH issues as a comment or anything

(Posted on the behalf of the client)


[Failed to download attachment: attachment_58501651__thumb_131973.png. Error: 401 Client Error: for url: Select Identity Provider - Jira - Idalko]

Answer by Jillani Fazal on 31 May 2023

  1. Sync assignees

We will map this, meaning, the JC email, to the GH id. Like this; (make sure the assignee is getting send over from Jira Cloud)

Put this on incoming GH side please;

def userMapping = [ "mathieu.lepoutre@idalko.com" : "mathieulepoutrebelgium”]
                issue.assignee = nodeHelper.getUserByUsername(userMapping[replica.assignee?.email])  
  
  

2. Sync Jira ticket status and map to GH statuses (closed or opened) if possible.

Put this on incoming GH side please;

def statusMap = [

       // "remote status name": "local status name"          
   		 "To Do" : "open" ,
         "Done" : "closed"     ]
def remoteStatusName = replica.status.name
issue.setStatus(statusMap[remoteStatusName] ?: remoteStatusName)  
  
  

3. Sync Jira releases (fixVersion) to Gihub milestones or labels:

Put this on outgoing JC side:

replica.fixVersions = issue.fixVersions
replica.affectedVersions = issue.affectedVersions
  

On the incoming sync in GitHub, please put this code;

if(firstSync){
issue.repository   = "mathieulepoutrebelgium/Exalate"
}
issue.summary      = replica.summary
issue.description  = replica.description
issue.comments     = commentHelper.mergeComments(issue, replica)
if(replica.fixVersions[0]){
   issue.labels += nodeHelper.getLabel("${replica.fixVersions[0].name}")
} 

We are going to check with an if-statement if a fixVersion was selected on the source (Jira Cloud) side, if so, we are adding the name as a label in GitHub.

The label has to exist before it is possible for Exalate to select it.

(updating as per the Mathieu’s replies to the client)