Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

How to specify different branch instead of master branch on AWS code deploy while using Github as source provider ? I see there is no option to select in the console to select branch(may be I missed).

I tried to checkout to different branch while we are in the pre_build phase, but it failed in the Download Source phase itself as the master branch doesn't have YAML file.

version: 0.1 phases:   install:     commands:       - apt-get update -y   pre_build:     commands:       - git checkout testbranch 
like image 693
bravokeyl Avatar asked Dec 05 '16 19:12

bravokeyl


People also ask

How do I link AWS CodeBuild to GitHub?

Connect GitHub with an access token (console)For Source provider, choose GitHub. For Repository, choose Connect with a GitHub personal access token. In GitHub personal access token, enter your GitHub personal access token. Choose Save token.

How do you encrypt the build artifacts that are stored by CodeBuild?

Q: Can I encrypt the build artifacts stored by CodeBuild? Yes. You can specify a key stored in the AWS Key Management Service (AWS KMS) to encrypt your artifacts.

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.


2 Answers

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.

like image 123
Clare Liguori Avatar answered Oct 09 '22 11:10

Clare Liguori


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

like image 35
sauce Avatar answered Oct 09 '22 12:10

sauce