Plan a build in AWS CodeBuild
Before you use AWS CodeBuild, you must answer these questions:
-
Where is the source code stored? CodeBuild currently supports building from the following source code repository providers. The source code must contain a build specification (buildspec) file. A buildspec is a collection of build commands and related settings, in YAML format, that CodeBuild uses to run a build. You can declare a buildspec in a build project definition.
Repository provider Required Documentation CodeCommit Repository name.
(Optional) Commit ID associated with the source code.
See these topics in the AWS CodeCommit User Guide:
Amazon S3 Input bucket name.
Object name corresponding to the build input ZIP file that contains the source code.
(Optional) Version ID associated with the build input ZIP file.
See these topics in the Amazon S3 Getting Started Guide:
GitHub Repository name.
(Optional) Commit ID associated with the source code.
See this topic on the GitHub Help website:
Bitbucket Repository name.
(Optional) Commit ID associated with the source code.
See this topic on the Bitbucket Cloud documentation website:
-
Which build commands do you need to run and in what order? By default, CodeBuild downloads the build input from the provider you specify and uploads the build output to the bucket you specify. You use the buildspec to instruct how to turn the downloaded build input into the expected build output. For more information, see the Buildspec reference.
-
Which runtimes and tools do you need to run the build? For example, are you building for Java, Ruby, Python, or Node.js? Does the build need Maven or Ant or a compiler for Java, Ruby, or Python? Does the build need Git, the AWS CLI, or other tools?
CodeBuild runs builds in build environments that use Docker images. These Docker images must be stored in a repository type supported by CodeBuild. These include the CodeBuild Docker image repository, Docker Hub, and Amazon Elastic Container Registry (Amazon ECR). For more information about the CodeBuild Docker image repository, see Docker images provided by CodeBuild.
-
Do you need AWS resources that aren't provided automatically by CodeBuild? If so, which security policies do those resources need? For example, you might need to modify the CodeBuild service role to allow CodeBuild to work with those resources.
-
Do you want CodeBuild to work with your VPC? If so, you need the VPC ID, the subnet IDs, and security group IDs for your VPC configuration. For more information, see Use AWS CodeBuild with Amazon Virtual Private Cloud.
After you have answered these questions, you should have the settings and resources you need to run a build successfully. To run your build, you can:
-
Use the AWS CodeBuild console, AWS CLI, or AWS SDKs. For more information, see Run builds manually.
-
Create or identify a pipeline in AWS CodePipeline, and then add a build or test action that instructs CodeBuild to automatically test your code, run your build, or both. For more information, see Use CodeBuild with CodePipeline.