# Bitbucket webhook - only trigger on Pull Request merge

**URL:** <https://discuss.bitrise.io/t/bitbucket-webhook-only-trigger-on-pull-request-merge/277>\
**Category:** Question & Answer\
**Tags:** bitbucket, webhook\
**Created:** [January 14, 2017, 6:04am UTC](https://discuss.bitrise.io/t/bitbucket-webhook-only-trigger-on-pull-request-merge/277 "2017-01-14T06:04:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![souleh](https://avatars.discourse-cdn.com/v4/letter/s/34f0e0/32.png) [@souleh](https://discuss.bitrise.io/u/souleh)\
**Post date:** [January 14, 2017, 6:04am UTC](https://discuss.bitrise.io/t/bitbucket-webhook-only-trigger-on-pull-request-merge/277/1 "2017-01-14T06:04:32Z")

</div>

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.

 ![](https://us1.discourse-cdn.com/flex016/uploads/bitrise/original/1X/cd76d820e9c27e905bb5271be05377f544ea7f36.png)

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”  
> }

 ![](https://us1.discourse-cdn.com/flex016/uploads/bitrise/original/1X/eb1888ee82fa5ee1addebbce6a4c0336698b49bb.png)

 ![](https://us1.discourse-cdn.com/flex016/uploads/bitrise/original/1X/38a90ac2713d932fe13a4ee54b0963435319268f.png)

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.

Thanks

Nick

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [January 14, 2017, 6:21am UTC](https://discuss.bitrise.io/t/bitbucket-webhook-only-trigger-on-pull-request-merge/277/2 "2017-01-14T06:21:06Z")

</div>

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 [bitrise.io](https://www.bitrise.io) / 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 [bitrise.io](https://www.bitrise.io)

To only build changes of the `staging` branch:

```auto
trigger_map:
- push_branch: "staging"
  workflow: primary

```

See: [http://devcenter.bitrise.io/webhooks/trigger-map/#how-to-build-only-a-single-branch](http://devcenter.bitrise.io/webhooks/trigger-map/#how-to-build-only-a-single-branch) - this trigger map config will only build code pushes and only on the `staging` branch.

More information and example configs: [http://devcenter.bitrise.io/webhooks/trigger-map/](http://devcenter.bitrise.io/webhooks/trigger-map/)

Let us know if you’d have any questions!

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [January 14, 2017, 7:30am UTC](https://discuss.bitrise.io/t/bitbucket-webhook-only-trigger-on-pull-request-merge/277/3 "2017-01-14T07:30:21Z")

</div>

A post was split to a new topic: [Slack - pinned items / links?](https://discuss.bitrise.io/t/slack-pinned-items-links/278)

---

<div class="post-metadata">

**Author:** ![MeGaPk](https://avatars.discourse-cdn.com/v4/letter/m/54ee81/32.png) [@MeGaPk](https://discuss.bitrise.io/u/MeGaPk)\
**Post date:** [November 20, 2017, 1:32pm UTC](https://discuss.bitrise.io/t/bitbucket-webhook-only-trigger-on-pull-request-merge/277/4 "2017-11-20T13:32:02Z")

</div>

@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”}

---

<div class="post-metadata">

**Author:** ![viktorbenei](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.bitrise.io/viktorbenei/32/18_2.png) [@viktorbenei](https://discuss.bitrise.io/u/viktorbenei)\
**Post date:** [November 21, 2017, 4:32pm UTC](https://discuss.bitrise.io/t/bitbucket-webhook-only-trigger-on-pull-request-merge/277/5 "2017-11-21T16:32:28Z")

</div>

Hi @MeGaPk

> [@MeGaPk](#):
>
> but have error in Bitrise server standalone, not cloud (stash)

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

In that case please see & vote/comment: [Add support for Bitbucket Server webhook format](http://discuss.bitrise.io/t/add-support-for-bitbucket-server-webhook-format/25)

---

<div class="post-metadata">

**Author:** ![MeGaPk](https://avatars.discourse-cdn.com/v4/letter/m/54ee81/32.png) [@MeGaPk](https://discuss.bitrise.io/u/MeGaPk)\
**Post date:** [November 21, 2017, 5:05pm UTC](https://discuss.bitrise.io/t/bitbucket-webhook-only-trigger-on-pull-request-merge/277/6 "2017-11-21T17:05:12Z")

</div>

yes, you are right 😃
