3

I'm using the groovy post build plugin.

http://wiki.hudson-ci.org/display/HUDSON/Groovy+Postbuild+Plugin

I'd like to access the username of the user who started the build. What is the correct variable for this?

Pablojim
  • 8,542
  • 8
  • 45
  • 69
  • If it was just a typo or an easy mistake, than please delete the question. – Peter Schuetze Oct 14 '10 at 14:27
  • There was a typo in the orginal title of this question it said "user whos tarted a build" I've fixed the question title but need an answer to it still! – Pablojim Oct 14 '10 at 14:40

3 Answers3

6

I'm running something that looks like this:

def build = manager.build   // "manager" for Groovy Postbuild plugin, only
def usercause=build.getCause(hudson.model.Cause$UserCause)
def thename=usercause.userName
Ken Bertelson
  • 2,510
  • 1
  • 15
  • 2
1

Looking at the Javadoc for the build variable, there is a method getCauses(). I think you can start there.

https://javadoc.jenkins-ci.org/index.html?hudson/model/Run.html

It's called causes because a user is not the only cause why a job gets build. SCM commits, time triggered or upward or downward build can also cause a build.

Tidhar Klein Orbach
  • 2,896
  • 2
  • 30
  • 47
ZeissS
  • 11,867
  • 4
  • 35
  • 50
0

jenkins 1.561

def userName = manager.build.getCause(hudson.model.Cause$UserIdCause).userName

Luan Nguyen
  • 111
  • 2
  • 4