Bitbucket webhook events
You can use webhook filter groups to specify which Bitbucket webhook events trigger a build. For example, you can specify that a build is only triggered for changes to specific branches.
You can create one or more webhook filter groups to specify which webhook events trigger a build. A build is triggered if any filter group evaluates to true, which occurs when all the filters in the group evaluate to true. When you create a filter group, you specify:
- An event
-
For Bitbucket, you can choose one or more of the following events:
-
PUSH -
PULL_REQUEST_CREATED -
PULL_REQUEST_UPDATED -
PULL_REQUEST_MERGED -
PULL_REQUEST_CLOSED
The webhook's event type is in its header in the
X-Event-Keyfield. The following table shows howX-Event-Keyheader values map to the event types.Note
You must enable the
mergedevent in your Bitbucket webhook setting if you create a webhook filter group that uses thePULL_REQUEST_MERGEDevent type. You must also enable thedeclinedevent in your Bitbucket webhook setting if you create a webhook filter group that uses thePULL_REQUEST_CLOSEDevent type.X-Event-KeyHeader valueEvent type repo:pushPUSHpullrequest:createdPULL_REQUEST_CREATEDpullrequest:updatedPULL_REQUEST_UPDATEDpullrequest:fulfilledPULL_REQUEST_MERGEDpullrequest:rejectedPULL_REQUEST_CLOSEDFor
PULL_REQUEST_MERGED, if a pull request is merged with the squash strategy and the pull request branch is closed, the original pull request commit no longer exists. In this case, theCODEBUILD_WEBHOOK_MERGE_COMMITenvironment variable contains the identifier of the squashed merge commit. -
- One or more optional filters
-
Use a regular expression to specify a filter. For an event to trigger a build, every filter within the group associated with it must evaluate to true.
ACTOR_ACCOUNT_ID(ACTOR_IDin the console)-
A webhook event triggers a build when a Bitbucket account ID matches the regular expression pattern. This value appears in the
account_idproperty of theactorobject in the webhook filter payload. HEAD_REF-
A webhook event triggers a build when the head reference matches the regular expression pattern (for example,
refs/heads/branch-nameandrefs/tags/tag-name). AHEAD_REFfilter evaluates the Git reference name for the branch or tag. The branch or tag name appears in thenamefield of thenewobject in thepushobject of the webhook payload. For pull request events, the branch name appears in thenamefield in thebranchobject of thesourceobject in the webhook payload. BASE_REF-
A webhook event triggers a build when the base reference matches the regular expression pattern. A
BASE_REFfilter works with pull request events only (for example,refs/heads/branch-name). ABASE_REFfilter evaluates the Git reference name for the branch. The branch name appears in thenamefield of thebranchobject in thedestinationobject in the webhook payload. FILE_PATH-
A webhook triggers a build when the path of a changed file matches the regular expression pattern.
COMMIT_MESSAGE-
A webhook triggers a build when the head commit message matches the regular expression pattern.
WORKFLOW_NAME-
A webhook triggers a build when the workflow name matches the regular expression pattern.
Note
You can find the webhook payload in the webhook settings of your Bitbucket repository.