1
0
-1

Hi I am sending issues from GitHub to Jira and I cannot figure out how to sync the Assignee's from GitHub over to Jira. I know that it has something to do with the email of the users and both users need to be registered in GitHub as well as Jira. But i have no idea what the Code should look like on either end.

  1. Ariel Aguilar

    Hi John,

    Have you tried to check on these docs:

    How to sync assignees on GitHub?

    Sync Jira issue user fields

    You'll find the proper way to achieve it there.

    Kind regards,

    Ariel

  2. John Roca

    I have seen these docs but I don't understand how I would go about applying them. the "How to sync assignee on Github" document states that when syncing from GitHub to Jira, Exalate takes the first assignee from the list and sends it to the Jira side. but has no code associated with this claim. The default command of Issue.assignee = replica.asignee does not seem to work either. 


    The second link only speaks to Jira to Jira sync.  which doesn't seem apply to what i need.


    I appreciate your response but i am still a little confused as to how to have the assignee from GitHub appear on Jira.

CommentAdd your comment...

1 answer

  1.  
    2
    1
    0

    Hi John,

    You can use on GitHub outgoing script:

    replica.assignee = issue.assignee 

    Then you can use on Jira incoming script:

    final def userMapping = [
          "johnroca" : "johnroca@company.com"
    ]
     issue.assignee = nodeHelper.getUserByEmail(userMapping[replica.assignee?.username])

    This should help you, let me know how it goes.

    Kind regards,

    Ariel

    1. John Roca

      Hey Ariel,

      this actually does work thank you! my only question is that i would now have to input all of the names and emails of the team members into the code(which is fine), but is there a way for it to auto read the assignees email on GitHub and cross reference with a users email on the Jira side? that way if new members are added or if someone changes there name on GitHub I wont have to revise the code.

    2. Ariel Aguilar

      Hi John,

      The assignee object retrieved from GitHub (Remember basically it is an API call done by Exalate) it is not returning email. It seems this was changed at some point because before the assignee object carried the email property. Now, you can only get the username or displayName for assignee, and you have to set up a mapping for each assignee if you want to get them right on Jira. Then, you are asking if new members can be added automatically. You can add a groovy string function like "startsWith" or "endsWith" or "contains", maybe add a prefix or suffix to GitHub usernames, and you might be able to make it work in a more "automatic" way but still it will require a similar effort since you will need to know what assignees correspond to what on the mapping and the mapping needs to be updated.


      Finally, you can add a debug error in case there is a new username not added to the mapping.

      final def userMapping = [
            "johnroca" : "johnroca@company.com"
      ]
      	def localReporter = nodeHelper.getUserByEmail(userMapping[replica.assignee?.username])
      if(!localReporter){
           debug.error("New user not found on mapping, please add: '${replica.assignee.username}'")
      }
      issue.assignee = localReporter

      Or use this option instead of generating an error, it will get you a default value:

      final def userMapping = [
            "johnroca" : "johnroca@company.com"
      ]
      	def localReporter = nodeHelper.getUserByEmail(userMapping[replica.assignee?.username])
      if(!localReporter){
        localReporter = nodeHelper.getUserByEmail("johnroca@company.com")
      }
      issue.assignee = localReporter

      Kind regards,

      Ariel

    CommentAdd your comment...