AWS CodeBuild is a fully managed continuous integration service that compiles source code, runs tests, and produces ready-to-deploy software packages.
Some key features of AWS CodeBuild include:
Create a buildspec.yml
file in the source code
The Buildspec file is a configuration file used to specify the steps to be performed in the build process when using the AWS CodeBuild service.
Contents of the buildspec.yml
file:
version: 0.2
phases:
install:
commands:
- apt-get update -y
- echo Installing hugo
- curl -L -o hugo.deb https://github.com/gohugoio/hugo/releases/download/v0.123.7/hugo_0.123.7_linux-amd64.deb
- dpkg -i hugo.deb
- hugo version
build:
commands:
- hugo -v
artifacts:
files:
- '**/*'
base-directory: 'public'
Push the new source code containing the buildspec.yml
file to CodeCommit
After creating the buildspec.yml
file, use the following commands to push the source code to CodeCommit
git add .
git commit -m "add buildspec.yml file"
git push
Access the AWS CodeBuild service or through the link AWS CodeBuild
Choose Create project
In the Create project interface:
Project configuration section: In the project name field, enter workshop-codebuild
Source section:
workshop-codecommit
Environment section:
Buildspec section:
buildspec.yml
(enter the location where the buildspec file is saved in step 1)Click Create Build project at the bottom of the page
Once the build project is created, you can test it by clicking the orange Start build button on the right. The result of the build process will be displayed on the Build history tab.