Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure AWS CodeBuild to build only when push to master branch is made?

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.

like image 237
Michał Urbaniak Avatar asked Apr 10 '19 07:04

Michał Urbaniak


People also ask

Where does AWS CodeBuild run your builds?

AWS CodeBuild runs your builds in preconfigured build environments that contain the operating system, programming language runtime, and build tools (e.g., Apache Maven, Gradle, npm) required to complete the task.

What are the build phases one can specify as part of the CodeBuild build specification?

These build phases are listed here as install , pre_build , build , and post_build . You cannot change the spelling of these build phase names, and you cannot create more build phase names. In this example, during the build phase, CodeBuild runs the mvn install command.


2 Answers

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

like image 128
Mark Adamson Avatar answered Sep 27 '22 00:09

Mark Adamson


You can set the filter group on the webhook, as explained in the documentation @ https://docs.aws.amazon.com/codebuild/latest/userguide/sample-github-pull-request.html#sample-github-pull-request-filter-webhook-events-console

like image 32
Subin Mathew Avatar answered Sep 27 '22 00:09

Subin Mathew