Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket Server GUI bypassing git server side hook?

BSP
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 27, 2016

We have configured a server side pre-receive hook to enforce a naming convention for the branch name. It works as expected when doing a push from local to server (source tree), where it doesn't allow developer to push a new branch with invalid name to the server.

But, if developer decided to use Bitbucket UI (Web) to create the branch, this hook is being bypassed, where developer can name the new branch to anything. Does Bitbucket UI not use the push to make changes to the Git server? or it is disabling/bypassing the pre-receive hook with some other mechanism. 

 

Any way to prevent Bitbucket UI from bypassing pre-receive hooks?

1 answer

1 accepted

1 vote
Answer accepted
adammarkham
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 27, 2016

The pre-receive hook will only get executed when you commit changes and do a git push to the server. If you are creating branches through the web UI you should add an event handler for the com.atlassian.bitbucket.event.branch.BranchCreationRequestedEvent.

To get the branch name you can do:

event.getBranch().getDisplayId()

Then to block creation you need to call:

event.cancel("Cancelling branch creation")

Additionally the current release of ScriptRunner for Bitbucket Server provides this functionality out of the box. Please see here for details of this.

Hope this helps.

 

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Upcoming Bitbucket Events