It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to customize Merge Check button in Bitbucket?

Cheuk Cheng Jun 09, 2016

Is there any event that can be handled by a custom event handle so that when a user clicks the Merge Check button on the pull request web page a pre-merge sanity build can be kicked off? If the sanity build passes then the merge can proceed. Otherwise, the merge will not happen.

I had already used a custom merge check to enable/disable the Merge Check button when certain conditions happened, e.g. allowed merge only when the ToRef branch was "feature/<name>". But in the above case we will like to save Jenkins resources by starting the sanity build only when the user clicks on the Merge Check button.

Thanks.

1 answer

1 accepted

0 votes
Answer accepted
JamieA Jun 09, 2016

Hi Cheuk,

I just wrote a really long answer and when I posted it this thing told me:

image2016-6-10 10:30:47.png

I can't face typing it all again, but approximately I said:

You should avoid doing this on a merge check. Merge checks should be quick and they run often.

One option might be to:

  • Add a merge-check that checks for the presence of some property on the PR
  • Add a new web-item in that location called "Ready to Merge" or something. This calls a REST endpoint that kicks off the build. 
  • If the build is successful it sets the PR property
  • Now PR can be merged

Another possible way is to add an event handler on GitMergeRequestedEvent, that, if no builds are associated with the PR, kicks one off, then calls .cancel() with a sensible error message.

If a passed build is associated with the PR it can allow the merge to proceed.

I'd be lying if I was to tell you that all this is super-easy.

 

 

Cheuk Cheng Jun 13, 2016

Hi Jamie.  Thanks for your suggestion and all the information.  My team will implement a new "Build" button for building.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

7,932 views 23 36
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you