Bitbucket Cloud: Stop push on webhook error Edited

I created a webhook in Bitbucket Cloud (Repository -> Push) that checks if the branch name is valid (bob_12345_ticket_description).

Branch must have the ticket number (12345) or it will throw an error (I tried a few different HTTP errors), with the purpose of stopping the push, come to find out it doesn't work how I thought it would (doesn't stop the push).

Is there a way to stop a push using a webhook?

1 answer

1 accepted

1 vote

Hi Michael! I think that in your case you should look into Git hooks:

Common use cases for Git hooks include encouraging a commit policy [...] 

The pre-commit script is executed every time you run git commit before Git asks the developer for a commit message or generates a commit object. You can use this hook to inspect the snapshot that is about to be committed. For example, you may want to run some automated tests that make sure the commit doesn’t break any existing functionality.

No arguments are passed to the pre-commit script, and exiting with a non-zero status aborts the entire commit.

Hope that helps!

Ana

So the answer is no :)

I did consider using git hooks but we have 10 devs and I didn't want them to have to spend time installing, and updating them.

I abandoned trying to stop them from pushing an invalid branch. I have checks in the pipelines instead, so the pipeline will fail.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Marketplace Apps

Tips on how to choose the best estimation method for your planning

Planning and grooming sessions all come with their own sets of rules. Team members meet to estimate stories or other work items, all according to an agreed-upon process. And with every session comes ...

85 views 0 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you