1
votes

AWS codebuild using Bitbucket source:

Under "Primary source webhook events Info"

and then under: "Start a build under these conditions"

How do you setup the HEAD_REF and BASE_REF properly to trigger a build only on a merge from any branch to the dev branch?

I have tried ^refs/heads/dev$ in the BASE_Ref field, but that didn't work. I have also confirmed that codebuild is connecting to bitbucket:

{ "response": "No build triggered for specified payload", "statusCode": 200 }

1

1 Answers

2
votes

Thank you for using AWS CodeBuild! For your use case, here's the sample steps:

  1. Go to AWS CodeBuild console, set up webhook for your Bitbucket source project. Put "^refs/heads/dev$" in BASE_REF text box, and choose PULL_REQUEST_MERGED for the event type.
  2. Once the webhook is created, check on Bitbucket page and find your webhook, and click edit. In "Triggers" -> "Pull Request", make sure you checked "Merged" checkbox. This makes sure Bitbucket will deliver pull request merge event payloads.
  3. Merge a pull request, and in the webhook request logs, look for requests with event type "pullrequest:fulfilled". This webhook event should trigger a CodeBuild build.

Please note a Bitbucket pull request merge event will deliver two webhook events, one with event type "pullrequest:fulfilled" and one with "repo:push". With the setting above, CodeBuild will build on the "pullrequest:fulfilled" payload.