• Icon: Suggestion Suggestion
    • Resolution: Fixed
    • None
    • None
    • None
    • We collect Bitbucket feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.

      It would be useful for people writing custom git hooks to have access to the authenticated user in their hooks.

      Stash currently authenticates users when they push to or pull from a Stash repository, but does not pass on the user to git. We could easily make the user available through an environment variable (e.g. USER, STASH_USER or GIT_USER)

            [BSERV-2555] Make authenticated user available to git hooks

            Katherine Yabut made changes -
            Workflow Original: JAC Suggestion Workflow [ 3392802 ] New: JAC Suggestion Workflow 3 [ 3613725 ]
            Status Original: RESOLVED [ 5 ] New: Closed [ 6 ]
            Monique Khairuliana (Inactive) made changes -
            Workflow Original: BSERV Suggestions Workflow [ 2683400 ] New: JAC Suggestion Workflow [ 3392802 ]
            Owen made changes -
            Workflow Original: Stash Workflow [ 388191 ] New: BSERV Suggestions Workflow [ 2683400 ]
            Status Original: Closed [ 6 ] New: Resolved [ 5 ]

            Stefan, we are trying the same .. but seems like the build fails as soon as we add the constructor to the pre-hook plugin.
            I have opened a question with details In regards to the same as below .. hopefully you can guide us.
            https://answers.atlassian.com/questions/32968488/how-to-retrieve-logged-in-userid-in-pre-receive-hook-plugin
            -Thanks in advance

            Parvinder added a comment - Stefan, we are trying the same .. but seems like the build fails as soon as we add the constructor to the pre-hook plugin. I have opened a question with details In regards to the same as below .. hopefully you can guide us. https://answers.atlassian.com/questions/32968488/how-to-retrieve-logged-in-userid-in-pre-receive-hook-plugin -Thanks in advance
            Stefan Saasen (Inactive) made changes -
            Fix Version/s Original: 1.1 [ 24692 ]
            Affects Version/s Original: 1.0.3 [ 26232 ]
            Assignee Original: TimP [ tim@atlassian.com ]
            Issue Type Original: Improvement [ 4 ] New: Suggestion [ 10000 ]
            Priority Original: Major [ 3 ]
            CharlesA made changes -
            Link New: This issue was cloned as STASH-3889 [ STASH-3889 ]

            Hi zaargy,

            It would be something along the lines of:

                // FooBar is the ctor
                public FooBar(StashAuthenticationContext authenticationContext) {
            

            and the following declaration in your atlassian-plugin.xml:

                <component-import key="stashAuthenticationContext" interface="com.atlassian.stash.user.StashAuthenticationContext" />
            

            In general, the best place to ask questions related to plugin development would be https://answers.atlassian.com/

            Cheers,
            Stefan

            Stefan Saasen (Inactive) added a comment - Hi zaargy , It would be something along the lines of: // FooBar is the ctor public FooBar(StashAuthenticationContext authenticationContext) { and the following declaration in your atlassian-plugin.xml : <component- import key= "stashAuthenticationContext" interface = "com.atlassian.stash.user.StashAuthenticationContext" /> In general, the best place to ask questions related to plugin development would be https://answers.atlassian.com/ Cheers, Stefan

            Hi,

            I am unable to work out how my repository hook is instantiated. What should the component constructor look like?

            Thanks,
            James

            James Gray added a comment - Hi, I am unable to work out how my repository hook is instantiated. What should the component constructor look like? Thanks, James

            mwatson added a comment -

            mwatson added a comment - No. Within a java hook, you should add the https://developer.atlassian.com/static/javadoc/stash/2.4.2/api/reference/com/atlassian/stash/user/StashAuthenticationContext.html to your plugin and component constructor and you'll be able to call the https://developer.atlassian.com/static/javadoc/stash/2.4.2/api/reference/com/atlassian/stash/user/StashAuthenticationContext.html#getCurrentUser( ) method. Matt

            James Gray added a comment -

            Hi,

            Is REMOTE_USER still applicable when using a Java plugin? I have modified the stash asynchronous post receive sample code to look for it and it does not seem to be set.

            Thanks,
            James

            James Gray added a comment - Hi, Is REMOTE_USER still applicable when using a Java plugin? I have modified the stash asynchronous post receive sample code to look for it and it does not seem to be set. Thanks, James

              Unassigned Unassigned
              mheemskerk Michael Heemskerk (Inactive)
              Votes:
              4 Vote for this issue
              Watchers:
              10 Start watching this issue

                Created:
                Updated:
                Resolved: