Get the user who initiated pre-receive hook

Hi, I´m trying to develop a pre-receive hook that do some work if the user who pushed the changes is a Jenkins-user.

I tried getting the current user from a AuthenticationContext but that doesn´t give me the user who initiated the hook. E.g if i change the user info in tortoiseGit-gui the user info does not change in the AuthenticationContext, and if I push to a local bitbucket server it says “admin” instead of my git user name.

So how can I get the user name from the user who pushed the changes?

Thanks in advance!

Hi @bugget_jr,

A single push can contain commits from multiple authors. Are you looking at getting the authors of the commits or the user who performed the push? The authentication context should give you the author who performed the push.

As for why the authentication context didn’t change when you changed the Tortoise Git info - how are you authenticating with Bitbucket? It is possible that your changes in Tortoise Git only changed the commit author not the Bitbucket authentication itself. If you are authenticating through ssh, then you will need to use the ssh key of a different user. If it is through http, then you will need to change the http config for your repo.

Hope this helps,
Kristy

Hi, thanks for the answer. I tested using HTTP and I realized that it was tahe user account that I was logged in into bitbucket that was the user I got with the authentication context.