Bitbucket webhook - only trigger on Pull Request merge

Hi there. I have three branches on my bitbucket repo, master, staging and develop. I only want my workflow to run when a pull request is merged in to my staging branch. Previously bitrise would trigger on pushes to develop, staging, all sorts, which I didn’t want as every little commit would use up one of my monthly builds.

I only have ‘Pull request: merged’ ticked in my bitbucket outgoing webhook. I do this because I only allow commits and pushes to develop; master and staging may only have a pull request merged in from the bitbucket web interface.

The webhook gets called OK but now I get a 400 response from Bitrise, and my build isn’t triggered:

“error”: “Failed to transform the webhook: X-Event-Key is not supported: pullrequest:fulfilled”

I can PM the request body if needed - I won’t paste it here as it has a lot of my app & repo specific details in.



1 Like

Thanks for the question @souleh!

So, the thing about Pull Request merges is that it is actuall a change (git push) on the target branch. When you merge the PR that generates a new commit on the PR’s target branch, and this is handled as a Git Push on / in the Trigger Map.

What you want for the use case you described is:

  1. Enable the Repository -> Push option of the Bitbucket Webhook
  2. Limit what kind of pushes to build using the Trigger Map on

To only build changes of the staging branch:

- push_branch: "staging"
  workflow: primary

See: - this trigger map config will only build code pushes and only on the staging branch.

More information and example configs:

Let us know if you’d have any questions!

A post was split to a new topic: Slack - pinned items / links?

@viktorbenei i have same problem, but have error in Bitrise server standalone, not cloud (stash):
{“error”:“Failed to transform the webhook: Issue with Headers: No Content-Type Header found”}

Hi @MeGaPk

You meant standalone / self hosted Bitbucket, not Bitrise, right?

In that case please see & vote/comment: Add support for Bitbucket Server webhook format

yes, you are right :smiley:

1 Like