views:

54

answers:

2

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?

+1  A: 

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

https://hudson.dev.java.net/nonav/javadoc/hudson/model/Run.html#getCauses()

Its 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.

ZeissS
+1  A: 

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
KenB