Reputation: 713
It seems Bitbucket Cloud doesn't allow to user server side hooks, so a pre-commit hook cannot be implemented. But it allows to use web hooks. But reading the BitBucket Cloud Documentation says that is more a notification system than some kind of hook that can be used to allow or reject an operation
After you create a webhook for an event, every time that event occurs, Bitbucket sends a payload request that describes the event to the specified URL. Thus, you can think of webhooks as a kind of notification system.
So my question is: Is it possible to simulate using webhooks some kind of filter used to allow or reject commits?
Upvotes: 2
Views: 2032
Reputation: 5660
No. The names are perhaps a little misleading, but git hooks and webhooks are unrelated.
Within Bitbucket (and GitHub, and GitLab, et al.), webhooks are only used for notification after a qualifying event (such as a push or a merge); they do not, and cannot, intervene when a bad commit happens on a local system. You could use a webhook to notify a CI system, though, and have the CI system test for whatever conditions you want to specify in the commit.
It's also worth pointing out here that pre-commit hooks are meant to be client-side - they don't get pushed, pulled, or cloned with the repo, and they only act on one copy of the repo at a time (so a pre-commit hook on my system won't stop you from making bad commits on your system). Pre-receive hooks are a bit different, since they can stay on a centralized system like Bitbucket and reject pushes, but for security reasons pre-receive hooks are tightly controlled on public repo hosts like Bitbucket.
Upvotes: 4