In this page

This page is specifically for Git repositories hosted by the Bitbucket Cloud service!

If you use Git, but not Bitbucket Cloud, please see the general Git guide instead.
Or, if you use Bitbucket Server, not Bitbucket Cloud, see the Bitbucket Server guide instead.

Working with Bitbucket Cloud commit policies

The problem with Bitbucket Cloud hooks

Bitbucket Cloud is a public cloud-based service operated by its own team. Unfortunately, the service does not allow customizing the server-side hooks in the Bitbucket Cloud repositories! It is by design.

They decided to disallow it, because customizing uncontrolled hooks could lead to stability problems and security issues, which would then destroy the Bitbucket Cloud experience. Again, it is a deliberate decision by the Bitbucket Cloud team, not a defect in Bitbucket Cloud and not a defect in Better Commit Policy.

Consequently, as Better Commit Policy relies on Git hooks, it is not possible to implement Better Commit Policy directly in the server-side Bitbucket Cloud repositories.

(Although Bitbucket Cloud supports webhooks, don't mix those: a webhook is not a Git hook! It cannot reject commits, so it does not help implementing commit policies, either.)

Read on, there is another approach you can take!

Using local hooks instead of Bitbucket Cloud hooks

What you can do is executing the verification in the developers' local repositories instead of the central repository. It works perfectly also with Bitbucket Cloud. If all developers install the hooks to their local clone repositories, you get the same level of safety as if you'd enforce the policy in the central repository.

There are no other limitations. All features of the Better Commit Policy app work also for Bitbucket Cloud hosted repositories.

Installing Bitbucket Cloud commit policies

The process looks like this:

  1. Create the commit policy.
  2. Ask your developers to install hook script of the policy to their local repositories. (It's a short self-service process everyone can complete in minutes.)

(Please note that a "share policy" feature that eases distributing and monitoring the hook script installation will be implemented soon. If it were valuable to you, vote to the public feature request.)

Has every team member installed the hook script?

First the bad news: this is not possible to strictly enforce the installation of the hook scripts. Why? If the hook script is not installed, then your Git is basically not talking to Jira, so Better Commit Policy cannot know about your repository at all.

Nevertheless, administrators still have the possibility to keep their eyes on the commits, to spot the ones that are eventually violating the policy. For example, if you know that the policy requires mentioning a Jira issue, and a committer is sending commits without that, then clearly: he forgot to install the hook script! Ask him to do so!

(We have an idea for a creative solution for this problem, using a post-mortem mechanism to automagically detect these missing installations. If this is valuable to you, please vote to the public feature request.)

Questions?

Ask us any time.