Why server side update hook does not fire when creating branch in stash

Im writing update hook which should be invoked when a new branch is created. The hook is invoked when the branch is created localy and then pushed to stash but not wen the branch is created through Stash gui. Why?

2 answers

1 accepted

0 vote

Git pre-receive-hook and post-receive-hooks are only triggered when you push changes to a repository, not when a branch or tag is created/updated or deleted locally. When you create a branch through the UI, the branch is created in the repository and no push is involved.

You could also listen for the BranchCreatedEvent or its supertype RepositoryRefsChangedEvent to get a callback whenever one or more refs are updated. Note that your event listener will receive these events for all repositories, so you might need to verify that your functionality should be enabled for the repository in question.

Relevant links: 

Thanks a lot! That was really fast answer!

I guess it is because it doesn't go through the same flow as a create branch commit goes through. you will probably need an asynchronous hook in order for it to work. 


Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
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...

2,028 views 1 5
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