How do I Two Way sync Status between Jira and GitHub

Originally asked by John Roca on 29 July 2021 (original question)


I am trying to sync up issues status between Jira and GitHub. I have it so that if I change status in Jira it will Change in GitHub but when I do it vice Verse Jira does not reflect the status change from GitHub. Can someone please review my script from both the Jira and GitHub Side.


Comments:

John Roca commented on 30 July 2021

hi Ariel Aguilar thanks for you help! I actually continued to mess around with the code it turned out that on the Jira side the words “Open” and “Closed” needed to start with a lowercase letter to match the form of the incoming status from GitHub. it now works. I appreciate your answer response though.

Answer by Ariel Aguilar on 30 July 2021

Hi there,

I see the problem is the mapping on the Jira incoming script. If the GitHub script is working from Jira to Gihub, then the Jira Incoming script should be something like:

def statusMap = [
            "Open": "To Do",
            "Working on it": "In Progress",
            "Closed" : "Done"
]
def remoteStatusName = replica.status.name
issue.setStatus(statusMap[remoteStatusName] ?: remoteStatusName)

Let me know if this works for you.

Kind regards,

Ariel