how to really enable one's own repository hook? Docs are pointing to UI only allowing search for marketplace ones.

The documentation talks about how to create one's own repository hooks but does not mention how to enable it. The UI only search for market place ones when I click on "Add Hooks". So the question is: what's the real flow of adding one's own hooks?

2 answers

1 accepted

Deshuang -

You would place your hook scripts in the "hooks" directory for your repository.  If you have SVN, it would looks something like:

/SVN
   /Repository-Name
      /hooks

There you can add your pre or post commit hooks.  For example there is a pre-commit hook that is available in the market place that allows you to restrict commits to your repository if there is not a valid JIRA ticket number in the comments section.  You would place the hook files (modified for your environment) into that /hooks directory and bounce your repository server. 

There may be some dependencies that you have to install depending on what your hook script is written in i.e. perl or python. 

Your script would do something like invoke the REST API to access JIRA, log in, and validate that the comment section of the commit contains a valid JIRA ticket number that is in "Open" status or whatever you need to verify.

Hope that helps some....

-Ed

Thanks for answering and that works. I also want to add a plugin so it shows in UI as well. Adam Ahmed has answered that part.

Writing your own hook involves creating one of those plugins and uploading it to your server through the Stash administration. 

 

Our developers docs go through how to create a repository hook plugin: https://developer.atlassian.com/stash/docs/latest/how-tos/repository-hooks.html

Thanks for your answer. The document is very useful. But where do I add that plug in to the server. I saw it only talks about testing it using another server within the SDK? Thanks, -Deshuang

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

654 views 0 4
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot