Hi Community,
We are using BitBucket cloud service to host all our Git repositories.
I would like to enforce some rule on each commit for some repositories. Technically I want to apply a Git commit hook on server side to valid any incoming push and allow/reject it by a bunch of checks.
On BitBucket cloud I can only find the configuration of Webhooks. From the documentation I was not able to clarify my following questions:
Thanks a lot, Roman
I think I found the answer (https://community.atlassian.com/t5/Bitbucket-questions/Does-Bitbucket-Cloud-support-git-pre-receive-hooks/qaq-p/950235):
Git pre-commit hook is currently support in BitBucket DataCenter, but NOT in BitBucket Cloud.
BitBucket WebHooks are NOT an equivalent to that.
There is a ticket pending (might need more votes): https://jira.atlassian.com/browse/BCLOUD-10471
Regards, Roman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Roman,
You can enable a webhook so every time you commit you can create a pull request, and manage a review of the code with that.
You can make a Bitbucket REST API call (via curl or postman) to enable/disable specific hooks programmatically.
1. GET your repo hook keys via /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks
2. PUT request for hook to be enabled (DELETE disables the hook) via /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/settings/hooks/{hookKey}/enabled
Best Regards
Laura
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks for you quick reply. Creating a PR on each commit is not exactly what I am looking for.
Actually I try to find a way on server side (BitBucket) to prevent a commit being stored in BitBucket Git repository.
This can be useful for a couple reason. Mainly when you want to apply a quality gate that needs to be passed before a commit is accepted. E.g. developer should follow a certain code format rule or the commit message must contain some required information.
Apply this on all developer systems is a high effort and can of course be bypassed by the developers easily.
So it is a better approach to ensure those things on Git server side by what is called a commit hook.
It is also possible to apply these quality gates later on (thru a central CI instance) but it is much more charme to apply some check already when the commit is send and reject it if checks are failing.
Regards, Roman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.