I've a script like as below for jenkins shared library and I would like to get users's slackID according to the user's email adress for passing this ID as parameter to the function.
How can I fetch the slackID according to the email address and then pass this value as parameter? What is the best way to do this?
Here is the shared-library script.
users = [
bennytheball: [
git: 'benny.ball@alley.way',
slack: '12345ABCD'
],
choochoo: [
git: 'choo.choo@alley.way',
slack: 'ABCD12345'
],
topcat: [
git: 'top.cat@alley.way',
slack: 'U9X76IJYA'
]
]
String email = sh(script: 'git show -s --pretty=%ae', returnStdout: true).trim()
def sendBuildStatusOverSlack(String authorSlackID = null) {
.....
}
Project Jenkinsfile
sendNotifications(authorSlackID)
You can get the according slack id like this
users.findAll { _, contact -> contact.git == email }
.collect { _, contact -> contact.slack }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.