Answer by Ariel Aguilar on 02 August 2021
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
Comments:
John Roca commented on 03 August 2021
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.
Ariel Aguilar commented on 04 August 2021
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