8
votes

I am using a webhook to build my project on push requests. By default, AWS CodeBuild builds on push to every branch, however I would like to limit that to master - to trigger the build ONLY when push to master is made. How do I use the regex patterns to do that?

The AWS documentation is not really specific in terms of how to use the regular expressions there.

2
Your problem has nothing to do with CodeBuild. You need to configure de "source" stage in your pipeline to listen to master branch. BTW, I didn't downvote. - Héctor
I don't use CodePipeline. I use CodeBuild only, sourcing the code from BitBucket and publishing the artifacts to S3 after the build. - Michał Urbaniak
@MichałUrbaniak any chance you can mark my answer as correct? It will be my first :) - Mark Adamson

2 Answers

12
votes

Set the HEAD_REF setting to ^refs/heads/master$. They don't explicitly specify it for master branch in the docs but they do show the equivalent for 'branch1'

source: https://docs.aws.amazon.com/codebuild/latest/userguide/sample-github-pull-request.html#sample-github-pull-request-filter-webhook-events-console