Getting user info during hooks implemented at git level


I am trying to implement a hook at the git level. I have a scenario as below:

-> I have a user who wants to create a branch. In my pre-receive hook, I am trying to fetch which user did the push, based on usernames stored in stash (using STASH API)..

Meaning, lets says I have user ishan and user ishah and both have same user info. (same name and email address)

Q: How does stash track which user is pushing into a project in STASH ???

-> For more, lets say "ishan" has permissions to write into that project and "ishah" does not have the permissions. How would stash differentiate between the users and limit ishah from not pushing but allowing ishan to push..

1 answer

This widget could not be displayed.

Hi GP,

Sorry for the delay. Are you talking about a Stash hook, or a git script?

If the former, you can use StashAuthenticatedContext to get the current Stash user. This class can be injected into the constructor of your pre-recieve hook.

If it's the latter you can use $REMOTE_USER which will contain the current Stash username.

I hope that helps?


Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in Statuspage

What are your best incident management tips and stories? #HugOps

 👋Community members! Downtime happens. And great incident response takes a village. Teams like Support, Dev, SRE, Ops, IT, and Marketing have to come together to resolve the problem while keep...

81 views 3 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you