Selecting other branch instead of master as a source repository on AWS CodeBuild

You can specify the branch in the "source version" field when you start a build. It will accept anything that "git checkout" accepts: commit ID, branch, tag, etc.


If you want to change the default branch (when not supplying a version in the individual build) from master to something else you have to use the AWS CLI as there is apparently no option in the UI:

aws codebuild update-project --name your_project_name --source-version your_default_branch

Adding a new source version at build time will still override this value per the docs:

If sourceVersion is specified at the project level, then this sourceVersion (at the build level) takes precedence.

https://docs.aws.amazon.com/codebuild/latest/APIReference/API_StartBuild.html#CodeBuild-StartBuild-request-sourceVersion