I have jobs with Jenkinsfiles where I can get the env.BUILD_USER_ID exposed by a Jenkins plugin. So, what I`m planning to do is associating this variable content to the Slack user ID value, like in a dictionary or list (or whatever).

e.g. johndoe@domain.com(env.BUILD_USER_ID) : 4555FDDGH(slack user)

and then, creating a condition at Jenkinsfile to evaluate if the env.BUILD_USER_ID value matches ANY of the slack users within the dictionary. With that info, I can mention the person who triggered a failing build, on a slack channel.

I was also thinking about storing this dictionary outside the jenkinsfile (maybe a JSON file on a different repo)

What are your sugestions on validating the env.BUILD_USER_ID along with the slack user, plus where it`s doable to store this info. I think having it at the Jenkinsfile it self is not secure and a bit sketchy to be honest.

  • There is no correlation in principle between slack ID and the email address identifying the person / entity who made the commit, so you need some form of lookup to make that match. This is probably best implemented as a shared library. Dec 8, 2021 at 6:55
  • @BruceBecker Actually, there is: the person that triggers the Job on Jenkins has it email associated to env.BUILD_USER_ID. That's the point: I can use this variable to create a dictonary to match with the slack users id list (which I already have btw). I just don't know how to do that.
    – the_piper
    Dec 8, 2021 at 12:34


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.