AWS CodeBuild is a fully-managed build service for compiling, testing and packaging code.
- Projects are the root of the pipeline configuration.
- Source is the input into the pipeline, and should be sourced from a repository containing a
- 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.
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 can be published to:
- S3 as objects.
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:
installis where you can install build dependencies onto the agent.
pre_buildallows preparing build configuration or vendoring dependencies.
buildis where the software is compiled.
post_buildis used for testing.
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.