In a hurry? No problem! Here’s a quick start to get going.
gem install cody cd <your-project> cody init # generates starter .cody files # edit .cody/buildspec.yml # git commit and push your changes. codebuild will git pull them down. cody deploy # create the CodeBuild project via CloudFormation cody start # start a CodeBuild project. Runs the buildspec.yml
Here are a little more details on what the summarized commands do. First, we install cody tool.
gem install cody
Change into your project directory.
If you do not have a project, simply create an empty folder.
mkdir demo cd demo
Create the starter .cody files in the project.
cody init # generates starter .cody files
An important generated file
.cody/buildspec.yml. The starter file looks something like this:
phases: install: runtime-versions: ruby: 2.6 build: commands: - echo Build started on `date` - uptime
All it does is run a
uptime command as part of the CodeProject build. Edit it for your needs. Remember to commit it and push it to the repo.
The CodeBuild project is defined in
.cody/project.rb via the Project DSL. It looks something like this:
github_url("https://github.com/tongueroo/demo-ufo") linux_image("aws/codebuild/amazonlinux2-x86_64-standard:2.0") environment_variables( JETS_ENV: "test" )
To define a project, it’s only 3 lines of code.
Make sure you push to github, since codebuild will be pulling from it.
git remote add origin email@example.com/user/repo # update with your own repo git add . git commit -m 'test commit' git push
Now we’re ready to deploy. You can deploy it with a single command:
This deploys a CloudFormation stack that creates a CodeBuild project and IAM role. The IAM role permissions is defined in
.cody/role.rb via the IAM Role DSL.
Once the stack is complete. You can start the CodeBuild project via the CLI or the CodeBuild console. Here is the CLI command:
Here’s what CodeBuild project output looks like:
Pro tip: Use the <- and -> arrow keys to move back and forward.