开发者

how do I get the username of the user who started a build in hudson

开发者 https://www.devze.com 2023-01-19 20:19 出处:网络
I\'m using the groovy post build plugin. http://wiki.hudson-ci.org/display/HUDSON/Groovy+Postbuild+Plugin

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?


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


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.


jenkins 1.561

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

0

精彩评论

暂无评论...
验证码 换一张
取 消