Automatically add a custom hook to post-receive.d in Stash 2.0.x?

In the past we have simply defined our custom hooks in <git_install_dir>/share/git-core/templates/hooks in order to have them included in all new repositories created by Stash.

In evaluating Stash 2.0.1, it appears that we need a way to automatically add our post-receive hook to <STASH_HOME>/data/repositories/<REPO_ID>/hooks/post-receive.d. I would really appreciate any suggestions on how to manage this. Thanks.

3 answers

Hi Jefferson,

After creating a new repository Stash should be moving your pre/post receive hooks to pre/post-receive.d/10_custom. It is also possible to create post-receive.d/10_your_script in the templates directory directly (only in Stash 2.0.1 though).

Longer term we're planning to manage hooks _in_ Stash as plugins rather than as shell scripts on the filesystem. This is how we implemented branch permissions, and we hope to enhance both the documentation and the APIs in an uncoming release. If you're interested watch/vote on the following issue:

I hope this helps.


PS. If you're just trying to do a task asynchronously after every push I have created a simple Stash plugin that demonstrates a Jenkins build hook, as well as mentioning relevant parts of our in-app hooks API as well.

Fantastic, Charles. Thanks very much for your support!

Hi Charles,

I have customized my post-receive hook to get email after every push. I have used atlassian SDK. So I have few java files and a soy template. How do I push them to my stash? Where exactly I have to copy it?

Please note that I want to do this only for one repository.



Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 14, 2019 in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder :  #!/bin/bash source "$(dirname "$0")/" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

312 views 0 12
Read article

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