Git server-side "pre-receive" hook (BB-11418)

Issue #10471 open
Maxim Novikov
created an issue

There are multiple cases when development teams want to check the push to the remote repository and either accept or reject it. Some may check branch names, commit messages, fast-forward merges, etc. to ensure the development process follows some particular rules.

Currently, it does not seem to be possible with Bitbucket to use this functionality that actually comes out of the box with Git. The user does not have access to the actual remote repository to manage that. However, it can be provided in a different way using the approach similar to Bitbucket Hooks' POST request. When the repository gets triggered on "pre-receive" event, it could execute HTTP POST request supplying all the information from the push, and accept it if the POST request returns 200 or reject if any other HTTP code. This would still not require to provide direct access to the remote repository, but the users could still handle commits and reject them using their specific rules.

PS Related but less generalized ticket:

Enhancement #5658 Allow custom pre-receive hook that rejects commits without an issue key in their message

Comments (10)

  1. Ferenc Kiss [Midori]


    This is exactly the concept that is now implemented by the Commit Policy add-on!

    This allow you to generate and install hook scripts to your local clones, with a simple to use wizard. Then at each commit, your changes are validated locally (by sending a request to JIRA and accepting or rejecting the change based on the returned result).

    Give this a free trial:

  2. Sam Krishna

    +1 To be clear, we want this functionality for bitbucket cloud. Not bitbucket server which is also another product by atlassian and which already has this available.

  3. Thomas Sondergaard

    Specific use case for our team. We use pre-tested merges, which means we allow allow only 'builduser' to update shared branches. In order to merge stuff to these branches developers have to push to another branch that is watched by jenkins. For example to merge a change to master you have to push to for-master/<some-branch>. I would really like to be able to check if for-master/<some-branch> is a fast-forward of master and block the push if it is not. I can do the check in our jenkins "integrate" job, but that can only give asynchronous feedback via email and other notification mechanisms. Immediate feedback would be much better.

  4. Ross Goldberg

    Are pre-receive hooks for Mercurial on BitBucket Cloud under the purview of this issue?

    If not, I’ll create a separate issue for it.

    If so, can you retitle this issue to indicate such?

    Is there any ETA for pre-receive hooks on Cloud?

    Is there any alternate method to reject pushes that do not meet certain criteria?


  5. Alex Atkinson

    Another basic feature that Atlassian's overlooked. Every time I look to see about a missing feature in one of their products there's always a ticket that's been open for years, or a closed ticket with the simple comment "functionality already exists in an addon..."

  6. Log in to comment