Reputation: 803
Lets say I have Global variable in Jenkins as below. these are actual user names of Jenkins.
Notify_Users = anne,raw,thoms,nandy
What I need is, get email addresses of these users from my pipeline script as I have correctly put their email addresses in each user properties under Manage user section in Jenkins.
The reason is I don't want to hard code users's email addresses in my Jenkinsfile. also I want to use this existing variable Notify_Users without creating new variable with email addresses, because we already use this variable for some other reason.
Since I'm very new for programming therefore couldn't find any point that I can start work on this. anyone can help me on this?
Upvotes: 0
Views: 2914
Reputation: 4678
In Jenkins you could have a look on hudson.model.User class.
With this you probably could
User u = User.getById(id, false)
def email = u.getProperty(Mailer.UserProperty.class)
print email.getAddress()
Upvotes: 1