Getting the current logged-in user from an Ant task running in Hudson
I'm using开发者_JAVA技巧 the "Hudson batch task plugin" to kick off some ant tasks after a build has run to deploy the build to a remote box.
As a part of the deploy the ant tasks writes a log record to a database. I'd like to be able to include the current user's username.
Does anybody know if the user's login is available to ant scripts running in Hudson? Maybe as an environment variable?
It is not available as an environment variable. This is because a single build can have many causes - it might be triggered by the timer trigger, and while queued, a user could request the build start as well. This would result in a build with two causes - the user and the timer trigger. It is also possible for multiple users to be the cause of the same build.
If you want to look up the causes, you should take a look at the XML api. You can do a wget/curl to the right URL, and you will see all the causes for the build.
精彩评论