CodeBuild
AWS CodeBuild is a fully-managed build service for compiling, testing and packaging code.
Concepts
- Projects are the root of the pipeline configuration.
- Source is the input into the pipeline, and should be sourced from a repository containing a
buildspec.yaml
file. - Source Providers get the source code to the CodeBuild service.
- Artifacts are outputs from builds, such as compiled binaries or log files from the build itself. These can be published on build failures as well as successful completions, enabling troubleshooting.
- Phases are the stages of build execution.
- Builds are executions of the pipeline. These have a status and logs generated by the run.
Source providers
Integrations are provided to make it easier to get source code into the service:
- Bitbucket allows fetching source code from a hosted Git repository.
- GitHub allows fetching source code from a hosted Git repository.
- S3 allows fetching objects from a specified S3 path.
Artifacts
Artifacts can be published to:
- S3 as objects.
Build specification
The build specification (buildspec.yml
) is written in YAML (Private) and can be placed in a buildspec.yaml
alongside the source or maintained in the CodeBuilds service:
version: 0.2
env:
variables:
TF_INPUT: 0
TF_IN_AUTOMATION: 1
parameter-store:
CREDS: some-parameter
phases:
build:
commands:
- terraform plan -out=plan.tfplan
artifacts:
files:
- plan.tfplan
The following phases can be configured in the build specification:
install
is where you can install build dependencies onto the agent.pre_build
allows preparing build configuration or vendoring dependencies.build
is where the software is compiled.post_build
is used for testing.
Artifacts:
files
Phases
SUBMITTED
PROVISIONING
DOWNLOAD_SOURCE
INSTALL
PRE_BUILD
BUILD
POST_BUILD
UPLOAD_ARTIFACTS
FINALIZING
COMPLETED
Caching
Source caching caches the repository's .git
directory, allowing for quicker fetches in the future. Enabling custom caching allows you to specify additional directories on the agent which should be retained. These can also be specified through the cache:paths
key of the BuildSpec.
Backlinks