5

I am running the below command to get the user who is currently logged into jenkins.

hudson.model.User.current()

But, the result i get is "SYSTEM". Does this mean that all builds in jenkins happen as SYSTEM user. And if that is the case, is the below approach, the only way to get the userID of the user who triggered the build?

for(hudson.model.Cause cause : build.causes) {
userBuild = cause.getUserName()
}

Actually, i am trying to edit the buildCaption.jelly in jenkins, so that only the user who triggered the build can cancel the build. And i am stuck at a point wherein i need to get the userid of the currently logged in user, so that i can check if he is the same as the user who started the build. Any ideas, please suggest. Thanks in advance.

burtsevyg
  • 3,851
  • 2
  • 29
  • 44
Iowa
  • 2,171
  • 4
  • 22
  • 31

0 Answers0