How can I send Epic Name from Jira to Github

Originally asked by Jose Lobo on 30 June 2021 (original question)


In GitHub, I want to see the issues associated to an epic. These epic values would come from Jira “Epic Name” field.

I want to send it to the Github “labels” field. However, the “label” field in Github is already populated with values

Is it possible to add a a new value to these labels with a preened like “EPIC-{Epic Name}” to differentiate the epics from common labels?

Also without deleting the already existing labels


Comments:

Ben Paz commented on 01 July 2021

Jose, Thanks for opening the question on my behalf.

1) Is the following possible?

For Jira to Github issue sync, the mapping should prepend the Jira epic name with “EPIC-”. The prepended name already exists in Github as a label.

Epic Example:

Jira: “Feature1”

Github: “EPIC-Feature1”

For Github to Jira issue sync, the mapping should find the label prepended with “EPIC-” and remove that prepended text. The remaining text should be mapped to the Jira issue’s epic name.

2) Is it possible for an issue sync to check if the epic name exists in the other system (Jira or Github)? So if the epic name does not exist then create the epic name for that issue sync. This is the scenario desired: In Jira, a user creates a new Epic, “Feature2”, and attaches to an issue. An Exalate sync is performed. Before, the mapping is completed, a query checks for the Epic name , “EPIC-Feature2” in Github and finds that it does not exist. Then the label “EPIC-Feature2” is created and then the issue is sync. Does this work in the reverse direction also.

Answer by Ariel Aguilar on 09 July 2021

Hi Ben,

1) What you are asking is a bit complex due to the Epic Link field. This special custom field displays the Epic Name, however its real value is the Epic issue key. If we see the replica of the object as the following example taken from the replica sent:

customFields": {
      "Epic Link": {
        "id": 10006,
        "name": "Epic Link",
        "uid": "10006",
        "type": "EPIC_LINK",
        "value": "TS-13"
      }

So, when Exalate accesses the field data, it can only retrieve the Epic issue key and not the Epic name. But still, for linked issues to an Epic, this might help:

Outgoing Jira:

replica.customFields."Epic Link" = issue.customFields"."Epic Link"

Incoming Zendesk:

def KeyToEpicName = ["TS-13": "Feature13", "Epic Issue Key 2": "Epic Name 2"]
def remoteValue = replica.customFields."Epic Link"?.value
def localLabel = nodeHelper.getLabel("EPIC-" + KeyToEpicName[remoteValue])
if(localLabel && !issue.labels.contains(localLabel)){
  issue.labels += localLabel
}

For Epics, you can just do:

Outgoing Jira:

replica.customFields."Epic Name" = issue.customFields"."Epic Name"

Incoming ZenDesk:

 if(replica.issueTypeName == "Epic" && !issue.labels.contains("EPIC-" + replica.customFields."Epic Name"?.value) {
issue.labels += nodeHelper.getLabel("EPIC-" + replica.customFields."Epic Name"?.value)
}

For the second question, if you want to do it in reverse maybe you can elaborate more if the label already exists and what exactly you want to do with the ticket once it has been “Exalated”, do you require to have it assigned to the corresponding Epic? This might require the usage of the httpClient. As reference, you can take a look at this:

https://docs.idalko.com/exalate/x/NQLuAg

Let me know if that helped,

Kind regards,

Ariel