9

I want to set a build webhook when a PullRequest is opened from dev branch to master branch. AWS Codebuild has a webhook based on HEAD_REF and BASE_REF which lacks detailed documentation.

What do they stand for?

qpzm
  • 320
  • 4
  • 12

1 Answers1

18

Thank you for using AWS CodeBuild. For pull request scenarios, HEAD_REF filters on the git reference name of the source branch in the webhook payload that triggers the webhook build, you can find the branch name in "pull_request" -> "head" -> "ref" field in the payload. BASE_REF filters on the git reference name of the destination branch in the payload, you can find the name in "pull_request" -> "base" -> "ref" field.

So for your use case (triggering build when a pr is opened from dev to master branch), you can put the reference name for master branch (e.g. "^refs/heads/master$") in BASE_REF, and reference name for dev branch (e.g. "^refs/heads/dev$") in HEAD_REF. Note the value you put for those two fitlers are regex, so you don't have to use the full name :)

Linghao Zhu
  • 441
  • 3
  • 3
  • Thank you for your detailed explanation! Is it actually documented somewhere? – qpzm Apr 02 '19 at 02:51
  • Currently no. But we are getting those details updated into our user guide. Thank you for bringing this to our attention :) – Linghao Zhu Apr 02 '19 at 22:00
  • This user guide is useful! https://docs.amazonaws.cn/en_us/codebuild/latest/userguide/sample-github-pull-request.html – qpzm Apr 22 '19 at 11:08