Bamboo PR create webhook from Bitbucket
Asked by Beau Herger:

Hello! We are using Bitbucket Cloud and Bamboo 9.2 (*edited, I had mistakenly said 9.3* ) with linked repos configured with the Bitbucket Cloud remote repository webhook (default events).   
We can see the webhook firing in the case of the pull request creation, and the return status is 204, but Bamboo is ignoring it.   
Is there some unwritten logic that Bamboo is applying around this hook event? e.g. there must be a new commit since the last build??


Answers:
author: Eduardo Alvarenga
body: Hello [@Beau Herger](/t5/user/viewprofilepage/user-id/833539)

Your setup looks correct.

To allow Bamboo to start a build after a Pull Request or Commit is pushed from the BBC Webhook, a "**Bitbucket Cloud repository triggered**" trigger needs to be added to the referred Plan "Triggers" tab, otherwise Bamboo will simply ignore the request.

Sincerely,

Eduardo Alvarenga  
Atlassian Support APAC

**--please don't forget to Accept the answer if the reply is helpful--**

comments: author: Beau Herger
body: Thanks for the response, Eduardo.  

We do have the cloud trigger set. We are following [Triggering a Bamboo build from Bitbucket Cloud using Webhooks](https://confluence.atlassian.com/bamboo0902/triggering-a-bamboo-build-from-bitbucket-cloud-using-webhooks-1236931317.html) exactly.

The problem remains that the creation of a pull request does not trigger a build in the following scenario.

* create a new branch, make a dummy commit, push
  * -\> bamboo creates new branch plan and executes
* wait ten minutes
* create a pull request on that branch
  * -\> bamboo receives the webhook, see log below
  * -\>X bamboo ++**DOES NOT EXECUTE**++

```

2023-06-07 09:39:43,731 INFO [AtlassianEvent::0-BAM::EVENTS:pool-2-thread-51] [BitbucketCloudWebhooksPullRequestsEventListener] Received pull request opened event [ from: msasafety/smartsensor_firmware ( feature/JTTC-1547-test ), to: msasafety/smartsensor_firmware ( develop ) ]
```


author: Eduardo Alvarenga
body: Hello [@Beau Herger](/t5/user/viewprofilepage/user-id/833539)

If a Plan branch already exists and Bamboo is already in sync with the repository's last commit revision, no builds will be triggered as it is already up to date. To validate that, create the Pull Request and update it with another commit, you'll see Bamboo will start a new build, meaning that your initial assumption is correct.

If you want to create a Plan branch only for Pull Requests, you need to modify the "Create plan branch" setting under the "Branches" tab on the Plan configuration and set it to "Pull Request".

As the Push payload is sent over the Pull Request webhook, Bamboo needs that setting

* [Automatic branch management](https://confluence.atlassian.com/bamboo/using-plan-branches-289276872.html#Usingplanbranches-Automaticbranchmanagement)

Sincerely,

Eduardo Alvarenga  
Atlassian Support APAC

**--please don't forget to Accept the answer if the reply is helpful--**


author: Beau Herger
body: Ok, thank you Eduardo. Your first sentence aligns with my assumption of what is going on. Webhooks events from the cloud are not a trigger *to build*, but a trigger to analyze the opportunity to build (if there is in fact a change). We made assumptions in our workflows in which we require a fresh build when a PR is created. It would be an improvement in the documentation if this caveat was made clear.