enthuguy
enthuguy

Reputation: 415

hudson: way to get the user value who initiated the build?

Is there a way to get the hudson job initiated user name. Is it possible to get using script shell, py etc.

Lets assume I have the build # which was initiated. I know how to get the latest build info using api but would like to get a user details for a specific job.

Do you think, this will work for hudson? :) https://wiki.jenkins-ci.org/display/JENKINS/Build+User+Vars+Plugin

Thanks in advance

Upvotes: 2

Views: 814

Answers (1)

Christopher Orr
Christopher Orr

Reputation: 111625

That plugin will not work with Hudson, unless you download a very old version of the plugin. I'm not sure how many people are still using Hudson and haven't upgraded to Jenkins.


Anyway, when a user manually triggers a build, this is called a "user cause"; there are other types of cause, e.g. SCM trigger.

You can use the JSON or XML API to get the causes for a build, for example:
https://ci.jenkins-ci.org/job/remoting/lastSuccessfulBuild/api/xml?xpath=//action/cause/userId

In this case, this returns the username that caused the build to run.
Though note that there may be multiple causes for a build, and potentially other cause types that use the userId field.

This works in Jenkins, but it should also work in Hudson, but I haven't tested it.

Upvotes: 1

Related Questions