Change build project settings in AWS CodeBuild (original) (raw)

You can use the AWS CodeBuild console, AWS CLI, or AWS SDKs to change a build project's settings.

If you add test reporting to a build project, make sure your IAM role has the permissions described in Test report permissions.

Topics

Change a build project's settings (console)

To change the settings for a build project, perform the following procedure:

  1. Open the AWS CodeBuild console at https://console.aws.amazon.com/codesuite/codebuild/home.
  2. In the navigation pane, choose Build projects.
  3. Do one of the following:
    • Choose the link for the build project you want to change, and then chooseBuild details.
    • Choose the button next to the build project you want to change, chooseView details, and then choose Build details.

You can modify the following sections:

Sections

Project configuration

In the Project configuration section, chooseEdit. When your changes are complete, choose Update configuration to save the new configuration.

You can modify the following properties.

Description

Enter an optional description of the build project to help other users understand what this project is used for.

Build badge

Select Enable build badge to make your project's build status visible and embeddable. For more information, see Build badges sample.

Note

Build badge does not apply if your source provider is Amazon S3.

Enable concurrent build limit

If you want to limit the number of concurrent builds for this project, perform the following steps:

  1. Select Restrict number of concurrent builds this project can start.
  2. In Concurrent build limit, enter the maximum number of concurrent builds that are allowed for this project. This limit cannot be greater than the concurrent build limit set for the account. If you try to enter a number greater than the account limit, an error message is displayed.

New builds are only started if the current number of builds is less than or equal to this limit. If the current build count meets this limit, new builds are throttled and are not run.

Enable public build access

To make your project's build results available to the public, including users without access to an AWS account, select Enable public build access and confirm that you want to make the build results public. The following properties are used for public build projects:

Public build service role

Select New service role if you want to have CodeBuild create a new service role for you, orExisting service role if you want to use an existing service role.

The public build service role enables CodeBuild to read the CloudWatch Logs and download the Amazon S3 artifacts for the project's builds. This is required to make the project's build logs and artifacts available to the public.

Service role

Enter the name of the new service role or an existing service role.

To make your project's build results private, clear Enable public build access.

For more information, see Get public build project URLs.

Warning

The following should be kept in mind when making your project's build results public:

Additional information

For Tags, enter the name and value of any tags that you want supporting AWS services to use. Use Add row to add a tag. You can add up to 50 tags.

Source

In the Source section, choose Edit. When your changes are complete, choose Update configuration to save the new configuration.

You can modify the following properties:

Source provider

Choose the source code provider type. Use the following lists to make selections appropriate for your source provider:

Note

CodeBuild does not support Bitbucket Server.

Amazon S3

Bucket

Choose the name of the input bucket that contains the source code.

S3 object key or S3 folder

Enter the name of the ZIP file or the path to the folder that contains the source code. Enter a forward slash (/) to download everything in the S3 bucket.

Source version

Enter the version ID of the object that represents the build of your input file. For more information, seeSource version sample with AWS CodeBuild.

CodeCommit

Repository

Choose the repository you want to use.

Reference type

Choose Branch, Git tag, orCommit ID to specify the version of your source code. For more information, see Source version sample with AWS CodeBuild.

Note

We recommend that you choose Git branch names that don't look like commit IDs, such as 811dd1ba1aba14473856cee38308caed7190c0d or 5392f7. This helps you avoid Git checkout collisions with actual commits.

Git clone depth

Choose to create a shallow clone with a history truncated to the specified number of commits. If you want a full clone, chooseFull.

Git submodules

Select Use Git submodules if you want to include Git submodules in your repository.

Bitbucket

Credential

Choose Default source credential or Custom source credential and follow the instructions to manage the default source credential or customize the source credential.

Connection type

Choose CodeConnections, OAuth, App password, or Personal access token to connect to CodeBuild.

Connection

Select a Bitbucket connection or a Secrets Manager secret to connect through your specified connection type.

Repository

Choose Repository in my Bitbucket account or Public repository and enter the repository URL.

Source version

Enter a branch, commit ID, tag, or reference and a commit ID. For more information, see Source version sample with AWS CodeBuild

Note

We recommend that you choose Git branch names that don't look like commit IDs, such as 811dd1ba1aba14473856cee38308caed7190c0d or 5392f7. This helps you avoid Git checkout collisions with actual commits.

Git clone depth

Choose Git clone depth to create a shallow clone with a history truncated to the specified number of commits. If you want a full clone, choose Full.

Git submodules

Select Use Git submodules if you want to include Git submodules in your repository.

Build status

Select Report build statuses to source provider when your builds start and finish if you want the status of your build's start and completion reported to your source provider.

To be able to report the build status to the source provider, the user associated with the source provider must have write access to the repo. If the user does not have write access, the build status cannot be updated. For more information, see Source provider access.

For Status context, enter the value to be used for the name parameter in the Bitbucket commit status. For more information, see build in the Bitbucket API documentation.

For Target URL, enter the value to be used for the url parameter in the Bitbucket commit status. For more information, see build in the Bitbucket API documentation.

The status of a build triggered by a webhook is always reported to the source provider. To have the status of a build that is started from the console or an API call reported to the source provider, you must select this setting.

If your project's builds are triggered by a webhook, you must push a new commit to the repo for a change to this setting to take effect.

In Primary source webhook events, select Rebuild every time a code change is pushed to this repository if you want CodeBuild to build the source code every time a code change is pushed to this repository. For more information about webhooks and filter groups, see Bitbucket webhook events.

GitHub

Credential

Choose Default source credential or Custom source credential and follow the instructions to manage the default source credential or customize the source credential.

Connection type

Choose GitHub App, OAuth, or Personal access token to connect to CodeBuild.

Connection

Select a GitHub connection or a Secrets Manager secret to connect through your specified connection type.

Repository

Choose Repository in my GitHub account, Public repository, or GitHub scoped webhook and enter the repository URL.

Source version

Enter a branch, commit ID, tag, or reference and a commit ID. For more information, see Source version sample with AWS CodeBuild

Note

We recommend that you choose Git branch names that don't look like commit IDs, such as 811dd1ba1aba14473856cee38308caed7190c0d or 5392f7. This helps you avoid Git checkout collisions with actual commits.

Git clone depth

Choose Git clone depth to create a shallow clone with a history truncated to the specified number of commits. If you want a full clone, choose Full.

Git submodules

Select Use Git submodules if you want to include Git submodules in your repository.

Build status

Select Report build statuses to source provider when your builds start and finish if you want the status of your build's start and completion reported to your source provider.

To be able to report the build status to the source provider, the user associated with the source provider must have write access to the repo. If the user does not have write access, the build status cannot be updated. For more information, see Source provider access.

For Status context, enter the value to be used for the context parameter in the GitHub commit status. For more information, see Create a commit status in the GitHub developer guide.

For Target URL, enter the value to be used for the target_url parameter in the GitHub commit status. For more information, see Create a commit status in the GitHub developer guide.

The status of a build triggered by a webhook is always reported to the source provider. To have the status of a build that is started from the console or an API call reported to the source provider, you must select this setting.

If your project's builds are triggered by a webhook, you must push a new commit to the repo for a change to this setting to take effect.

In Primary source webhook events, select Rebuild every time a code change is pushed to this repository if you want CodeBuild to build the source code every time a code change is pushed to this repository. For more information about webhooks and filter groups, see GitHub webhook events.

GitHub Enterprise Server

Credential

Choose Default source credential or Custom source credential and follow the instructions to manage the default source credential or customize the source credential.

Connection type

Choose CodeConnections or Personal access token to connect to CodeBuild.

Connection

Select a GitHub Enterprise connection or a Secrets Manager secret to connect through your specified connection type.

Repository

Choose Repository in my GitHub Enterprise account or GitHub Enterprise scoped webhook and enter the repository URL.

Source version

Enter a pull request, branch, commit ID, tag, or reference and a commit ID. For more information, see Source version sample with AWS CodeBuild.

Note

We recommend that you choose Git branch names that don't look like commit IDs, such as 811dd1ba1aba14473856cee38308caed7190c0d or 5392f7. This helps you avoid Git checkout collisions with actual commits.

Git clone depth

Choose Git clone depth to create a shallow clone with a history truncated to the specified number of commits. If you want a full clone, choose Full.

Git submodules

Select Use Git submodules if you want to include Git submodules in your repository.

Build status

Select Report build statuses to source provider when your builds start and finish if you want the status of your build's start and completion reported to your source provider.

To be able to report the build status to the source provider, the user associated with the source provider must have write access to the repo. If the user does not have write access, the build status cannot be updated. For more information, see Source provider access.

For Status context, enter the value to be used for the context parameter in the GitHub commit status. For more information, see Create a commit status in the GitHub developer guide.

For Target URL, enter the value to be used for the target_url parameter in the GitHub commit status. For more information, see Create a commit status in the GitHub developer guide.

The status of a build triggered by a webhook is always reported to the source provider. To have the status of a build that is started from the console or an API call reported to the source provider, you must select this setting.

If your project's builds are triggered by a webhook, you must push a new commit to the repo for a change to this setting to take effect.

Insecure SSL

Select Enable insecure SSL to ignore SSL warnings while connecting to your GitHub Enterprise project repository.

In Primary source webhook events, select Rebuild every time a code change is pushed to this repository if you want CodeBuild to build the source code every time a code change is pushed to this repository. For more information about webhooks and filter groups, see GitHub webhook events.

GitLab

Credential

Choose Default source credential or Custom source credential and follow the instructions to manage the default source credential or customize the source credential.

Connection type

CodeConnections is used to connect GitLab to CodeBuild.

Connection

Select a GitLab connection to connect through CodeConnections.

Repository

Choose the repository you want to use.

Source version

Enter a pull request ID, branch, commit ID, tag, or reference and a commit ID. For more information, see Source version sample with AWS CodeBuild.

Note

We recommend that you choose Git branch names that don't look like commit IDs, such as 811dd1ba1aba14473856cee38308caed7190c0d or 5392f7. This helps you avoid Git checkout collisions with actual commits.

Git clone depth

Choose Git clone depth to create a shallow clone with a history truncated to the specified number of commits. If you want a full clone, choose Full.

Build status

Select Report build statuses to source provider when your builds start and finish if you want the status of your build's start and completion reported to your source provider.

To be able to report the build status to the source provider, the user associated with the source provider must have write access to the repo. If the user does not have write access, the build status cannot be updated. For more information, see Source provider access.

GitLab Self Managed

Credential

Choose Default source credential or Custom source credential and follow the instructions to manage the default source credential or customize the source credential.

Connection type

CodeConnections is used to connect GitLab Self Managed to CodeBuild.

Connection

Select a GitLab Self Managed connection to connect through CodeConnections.

Repository

Choose the repository you want to use.

Source version

Enter a pull request ID, branch, commit ID, tag, or reference and a commit ID. For more information, see Source version sample with AWS CodeBuild.

Note

We recommend that you choose Git branch names that don't look like commit IDs, such as 811dd1ba1aba14473856cee38308caed7190c0d or 5392f7. This helps you avoid Git checkout collisions with actual commits.

Git clone depth

Choose Git clone depth to create a shallow clone with a history truncated to the specified number of commits. If you want a full clone, choose Full.

Build status

Select Report build statuses to source provider when your builds start and finish if you want the status of your build's start and completion reported to your source provider.

To be able to report the build status to the source provider, the user associated with the source provider must have write access to the repo. If the user does not have write access, the build status cannot be updated. For more information, see Source provider access.

Environment

In the Environment section, choose Edit. When your changes are complete, choose Update configuration to save the new configuration.

You can modify the following properties:

Provisioning model

To change the provisioning model, choose Change provisioning model and do one of the following:

For information, see Run builds on reserved capacity fleets.

Environment image

To change the build image, choose Override image and do one of the following:

Note

CodeBuild overrides the ENTRYPOINT for custom Docker images.

Service role

Do one of the following:

Note

When you use the console to create a build project, you can create a CodeBuild service role at the same time. By default, the role works with that build project only. If you use the console to associate this service role with another build project, the role is updated to work with the other build project. A service role can work with up to 10 build projects.

Additional configuration

Timeout

Specify a value, between 5 minutes and 36 hours, after which CodeBuild stops the build if it is not complete. Ifhours and minutes are left blank, the default value of 60 minutes is used.

Privileged

Select Enable this flag if you want to build Docker images or want your builds to get elevated privileges. only if you plan to use this build project to build Docker images. Otherwise, all associated builds that attempt to interact with the Docker daemon fail. You must also start the Docker daemon so that your builds can interact with it. One way to do this is to initialize the Docker daemon in the install phase of your build spec by running the following build commands. Do not run these commands if you chose a build environment image provided by CodeBuild with Docker support.

Note

By default, Docker daemon is enabled for non-VPC builds. If you would like to use Docker containers for VPC builds, see Runtime Privilege and Linux Capabilities on the Docker Docs website and enable privileged mode. Also, Windows does not support privileged mode.

- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2 &
- timeout 15 sh -c "until docker info; do echo .; sleep 1; done"

VPC

If you want CodeBuild to work with your VPC:

For more information, see Use AWS CodeBuild with Amazon Virtual Private Cloud.

Compute

Choose one of the available options.

Registry credential

Specify a registry credential when the project is configured with a non-private registry image.

Note

This credential will only be utilized if the images are overridden with those from private registries.

Environment variables

Enter the name and value, and then choose the type of each environment variable for builds to use.

Note

CodeBuild sets the environment variable for your AWS Region automatically. You must set the following environment variables if you haven't added them to your buildspec.yml:

Console and AWS CLI users can see environment variables. If you have no concerns about the visibility of your environment variable, set the Name andValue fields, and then setType toPlaintext.

We recommend that you store an environment variable with a sensitive value, such as an AWS access key ID, an AWS secret access key, or a password as a parameter in Amazon EC2 Systems Manager Parameter Store or AWS Secrets Manager.

If you use Amazon EC2 Systems Manager Parameter Store, then forType, chooseParameter. ForName, enter an identifier for CodeBuild to reference. For Value, enter the parameter's name as stored in Amazon EC2 Systems Manager Parameter Store. Using a parameter named /CodeBuild/dockerLoginPassword as an example, for Type, chooseParameter. ForName, enterLOGIN_PASSWORD. For Value, enter /CodeBuild/dockerLoginPassword.

Important

If you use Amazon EC2 Systems Manager Parameter Store, we recommend that you store parameters with parameter names that start with /CodeBuild/ (for example, /CodeBuild/dockerLoginPassword). You can use the CodeBuild console to create a parameter in Amazon EC2 Systems Manager. Choose Create parameter, and then follow the instructions in the dialog box. (In that dialog box, for KMS key, you can specify the ARN of an AWS KMS key in your account. Amazon EC2 Systems Manager uses this key to encrypt the parameter's value during storage and decrypt it during retrieval.) If you use the CodeBuild console to create a parameter, the console starts the parameter name with /CodeBuild/ as it is being stored. For more information, see Systems Manager Parameter Store and Systems Manager Parameter Store Console Walkthrough in the_Amazon EC2 Systems Manager User Guide_.

If your build project refers to parameters stored in Amazon EC2 Systems Manager Parameter Store, the build project's service role must allow thessm:GetParameters action. If you chose New service role earlier, CodeBuild includes this action in the default service role for your build project. However, if you chose Existing service role, you must include this action to your service role separately.

If your build project refers to parameters stored in Amazon EC2 Systems Manager Parameter Store with parameter names that do not start with /CodeBuild/, and you chose New service role, you must update that service role to allow access to parameter names that do not start with/CodeBuild/. This is because that service role allows access only to parameter names that start with/CodeBuild/.

If you choose New service role, the service role includes permission to decrypt all parameters under the/CodeBuild/ namespace in the Amazon EC2 Systems Manager Parameter Store.

Environment variables you set replace existing environment variables. For example, if the Docker image already contains an environment variable namedMY_VAR with a value of my_value, and you set an environment variable named MY_VAR with a value ofother_value, then my_value is replaced byother_value. Similarly, if the Docker image already contains an environment variable named PATH with a value of/usr/local/sbin:/usr/local/bin, and you set an environment variable named PATH with a value of$PATH:/usr/share/ant/bin, then/usr/local/sbin:/usr/local/bin is replaced by the literal value $PATH:/usr/share/ant/bin.

Do not set any environment variable with a name that begins withCODEBUILD_. This prefix is reserved for internal use.

If an environment variable with the same name is defined in multiple places, the value is determined as follows:

If you use Secrets Manager, for Type, chooseSecrets Manager. ForName, enter an identifier for CodeBuild to reference. For Value, enter areference-key using the pattern`secret-id`:`json-key`:`version-stage`:`version-id`. For information, see Secrets Manager reference-key in the buildspec file.

Important

If you use Secrets Manager, we recommend that you store secrets with names that start with /CodeBuild/ (for example,/CodeBuild/dockerLoginPassword). For more information, seeWhat Is AWS Secrets Manager? in the AWS Secrets Manager User Guide.

If your build project refers to secrets stored in Secrets Manager, the build project's service role must allow thesecretsmanager:GetSecretValue action. If you choseNew service role earlier, CodeBuild includes this action in the default service role for your build project. However, if you chose Existing service role, you must include this action to your service role separately.

If your build project refers to secrets stored in Secrets Manager with secret names that do not start with /CodeBuild/, and you chose New service role, you must update the service role to allow access to secret names that do not start with /CodeBuild/. This is because the service role allows access only to secret names that start with /CodeBuild/.

If you choose New service role, the service role includes permission to decrypt all secrets under the/CodeBuild/ namespace in the Secrets Manager.

Buildspec

In the Buildspec section, choose Edit. When your changes are complete, choose Update configuration to save the new configuration.

You can modify the following properties:

Build specifications

Do one of the following:

For more information, see the Buildspec reference.

Batch configuration

In the Batch configuration section, chooseEdit. When your changes are complete, choose Update configuration to save the new configuration. For more information, seeRun builds in batches.

You can modify the following properties:

Batch service role

Provides the service role for batch builds.

Choose one of the following:

Batch builds introduce a new security role in the batch configuration. This new role is required as CodeBuild must be able to call the StartBuild, StopBuild, andRetryBuild actions on your behalf to run builds as part of a batch. Customers should use a new role, and not the same role they use in their build, for two reasons:

Allowed compute types for batch

Select the compute types allowed for the batch. Select all that apply.

Allowed fleets for batch

Select the fleets allowed for the batch. Select all that apply.

Maximum builds allowed in batch

Enter the maximum number of builds allowed in the batch. If a batch exceeds this limit, the batch will fail.

Batch timeout

Enter the maximum amount of time for the batch build to complete.

Combine artifacts

Select Combine all artifacts from batch into a single location to have all of the artifacts from the batch combined into a single location.

Batch report mode

Select the desired build status report mode for batch builds.

Note

This field is only available when the project source is Bitbucket, GitHub, or GitHub Enterprise, and Report build statuses to source provider when your builds start and finish is selected under Source.

Aggregated builds

Select to have the statuses for all builds in the batch combined into a single status report.

Individual builds

Select to have the build statuses for all builds in the batch reported separately.

Artifacts

In the Artifacts section, choose Edit. When your changes are complete, choose Update configuration to save the new configuration.

You can modify the following properties:

Type

Do one of the following:

For each secondary set of artifacts you want:

  1. For Artifact identifier, enter a value that is fewer than 128 characters and contains only alphanumeric characters and underscores.
  2. Choose Add artifact.
  3. Follow the previous steps to configure your secondary artifacts.
  4. Choose Save artifact.

Additional configuration

Encryption key

Do one of the following:

Cache type

For Cache type, choose one of the following:

Note

Docker layer cache mode is available for Linux only. If you choose it, your project must run in privileged mode.

Using a cache saves considerable build time because reusable pieces of the build environment are stored in the cache and used across builds. For information about specifying a cache in the buildspec file, see Buildspec syntax. For more information about caching, see Cache builds to improve performance.

Logs

In the Logs section, choose Edit. When your changes are complete, choose Update configuration to save the new configuration.

You can modify the following properties:

Choose the logs you want to create. You can create Amazon CloudWatch Logs, Amazon S3 logs, or both.

CloudWatch

If you want Amazon CloudWatch Logs logs:

CloudWatch logs

Select CloudWatch logs.

Group name

Enter the name of your Amazon CloudWatch Logs log group.

Stream name

Enter your Amazon CloudWatch Logs log stream name.

S3

If you want Amazon S3 logs:

S3 logs

Select S3 logs.

Bucket

Choose the name of the S3 bucket for your logs.

Path prefix

Enter the prefix for your logs.

Disable S3 log encryption

Select if you do not want your S3 logs encrypted.

Change a build project's settings (AWS CLI)

For information about using the AWS CLI with AWS CodeBuild, see the Command line reference.

To update a CodeBuild project with the AWS CLI, you create a JSON file with the updated properties and pass that file to the update-project command. Any properties not contained in the update file remain unchanged.

In the update JSON file, only the name property and the modified properties are required. The name property identifies the project to modify. For any modified structures, the required parameters for those structures must also be included. For example, to modify the environment for the project, the environment/type andenvironment/computeType properties are required. Here is an example that updates the environment image:

{
  "name": "<project-name>",
  "environment": {
    "type": "LINUX_CONTAINER",
    "computeType": "BUILD_GENERAL1_SMALL",
    "image": "aws/codebuild/amazonlinux-x86_64-standard:4.0"
  }
}

If you need to obtain the current property values for a project, use the batch-get-projects command to obtain the current properties of the project you are modifying, and write the output to a file.

aws codebuild batch-get-projects --names "<project-name>" > project-info.json

The project-info.json file contains an array of projects, so it cannot be used directly to update a project. You can, however, copy the properties that you want to modify from the project-info.json file and paste them into your update file as a baseline for the properties you want to modify. For more information, see View a build project's details (AWS CLI).

Modify the update JSON file as described in Create a build project (AWS CLI), and save your results. When you are finished modifying the update JSON file, run the update-project command, passing the update JSON file.

aws codebuild update-project --cli-input-json file://<update-project-file>

If successful, the updated project JSON appears in the output. If any required parameters are missing, an error message is displayed in the output that identifies the missing parameters. For example, this is the error message displayed if theenvironment/type parameter is missing:

aws codebuild update-project --cli-input-json file://update-project.json

Parameter validation failed:
Missing required parameter in environment: "type"

Change a build project's settings (AWS SDKs)

For information about using AWS CodeBuild with the AWS SDKs, see the AWS SDKs and tools reference.