Hi, I'd like to enable and disable hooks, like: 'Reject Force Push', through script.
Is it possible? Exists API to do that action?
Thanks!
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
As a general practice for automating UI tasks, play the scenario in the UI and log the XHR data requests in the browser console. This gives you a good idea what to look for in the REST API spec.
Let me know if that approach works for you.
Best, Ulrich
Izymes - Remove boring from work
Hey @Ulrich Kuhnhardt _IzymesCo_
thanks so much about your explanation.
I got it and my automation works now.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Raphael Viana
Welcome to the community!
Currently, Bitbucket doesn't support the Hooks feature. We do have an existing feature request on this, please Vote & Watch the feature request so that you'll receive an update if we have any at:
Meantime, you may want to look into an alternate feature Bitbucket has which is Branch permission where you can enforce specific workflows and prevent errors like a new workspace member deleting the main branch or pushing to branch without creating pull request and approved.
Feel free to let me know if you have any additional questions.
Cheers,
Syahrul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Syahrul
I'd like to check that information.
In BitBuket server we can't enable or disable pre-receive hook with API or
another script access, that action is only possible manually. Correct?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Apologize for that as I thought you were asking about Bitbucket cloud. If you are looking into Bitbucket server, I believe this documentation could help you:
If you still failing to enable or use your pre-hook I would suggest you raise a support ticket for further assistance.
I hope this helps.
Cheers,
Syahrul
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Syahrul
It's possible to enable or disable the hooks using traditional API path as @Ulrich Kuhnhardt _IzymesCo_ said.
It's a great point to put in tutorial or any other content.
As complementing: PUT verb enable hook and Delete disable, so by this way we can control hooks passing his key (obtained through GET to the same endpoint).
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.