AWS CodeBuild: A Fully Managed Build Tool

AWS CodeBuild is a fully managed continuous integration (CI) service that compiles source code, runs tests, and produces software packages that are ready to deploy.

With CodeBuild, you don’t need to provision, manage, and scale your own build servers.CodeBuild scales continuously and processes multiple builds concurrently, so your builds are not left waiting in a queue.CodeBuild is an alternative to other build tools such as Jenkins.CodeBuild scales continuously and processes multiple builds concurrently. You pay based on the time it takes to complete the 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 and It is possible to extend capabilities by leveraging your own Docker images.

CodeBuild is integrated with KMS for encryption of build artifacts, IAM for build permissions, VPC for network security, and CloudTrail for logging API calls.CodeBuild takes source code from GitHub, CodeCommit, CodePipleine, S3, etc. Build instructions can be defined in the code (buildspec.yml).Output logs can be sent to Amazon S3 & AWS CloudWatch Logs. There are metrics to monitor CodeBuild statistics. You can use CloudWatch alarms to detect failed builds and trigger SNS notifications. Builds can be defined within CodePipeline or CodeBuild itself.

CodeBuild Concepts

Build project – defines how CodeBuild will run a build defines settings including

*Location of the source code.

*The build environment to use.

*The build commands to run.

*Where to store the output of the build.

*Build environment

The operating system, language runtime, and tools that CodeBuild uses for the build.

*Build Specification 

YAML file that describes the collection of commands and settings for CodeBuild to run a build

Preconfigured build environments

AWS CodeBuild provides build environments for Java, Python, Node.js, Ruby, Go, Android, .NET Core for Linux, and Docker.

Customized build environments

You can bring your own build environments to use with AWS CodeBuild, such as for the Microsoft .NET Framework. You can package the runtime and tools for your build into a Docker image and upload it to a public Docker Hub repository or Amazon EC2 Container Registry (Amazon ECR).

When you create a new build project, you can specify the location of your Docker image, and CodeBuild will pull the image and use it as the build project configuration.

Specifying build commands

You can define the specific commands that you want AWS CodeBuild to perform, such as installing build tool packages, running unit tests, and packaging your code. The build specification is a YAML file that lets you choose the commands to run at each phase of the build and other settings.CodeBuild helps you get started quickly with sample build specification files for common scenarios, such as builds using Apache Maven, Gradle, or npm.

The code sample shows the contents of a buildspec.yml file that is being used to build a Docker image and push it to the Amazon Elastic Container Registry (ECR)

version: 0.2




docker: 18



- echo Logging in to Amazon ECR...

- $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)



- echo Build started on `date`

- echo Building the Docker image...

- docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG .




- echo Build completed on `date`

- echo Pushing the Docker image...

- docker push $AWS_ACCOUNT_ID.dkr.ecr.$$IMAGE_REPO_NAME:$IMAGE_TAG

You can define environment variables

*Plaintext variables.

Recent Comments

No comments

Leave a Comment