Retry builds automatically in AWS CodeBuild
You can use the AWS CodeBuild console, AWS CLI, or AWS SDKs to automatically retry your builds in AWS CodeBuild. With auto-retry enabled,
CodeBuild will automatically call RetryBuild using the project's service role after a failed build up to a specified limit. For example, if the
auto-retry limit is set to two, CodeBuild will call the RetryBuild API to automatically retry your build for up to two additional times.
Note
CodeBuild does not support auto-retry for CodePipeline.
Topics
Retry a build automatically (console)
-
Open the AWS CodeBuild console at https://console.aws.amazon.com/codesuite/codebuild/home
. -
Choose Create project. For information, see Create a build project (console) and Run a build (console).
-
In Environment:
-
For Auto-retry limit, enter the maximum number of auto-retries desired after a failed build.
-
-
-
In Environment, choose Additional configuration.
-
Continue with the default values and then choose Create build project.
Retry a build automatically (AWS CLI)
-
Run the create-project command:
aws codebuild create-project \ --name "<project-name>" \ --auto-retry-limit<auto-retry-limit>\ --source "<source>" \ --artifacts {<artifacts>} \ --environment "{\"type\": \"environment-type>\",\"image\": \"image-type>\",\"computeType\": \"compute-type>\"}" \ --service-role "service-role>"In the preceding command, replace the following placeholders:
-
<auto-retry-limit>: Set the auto-retry limit to the maximum number of auto-retries desired after a failed build. -
<project-name>,<source>,<artifacts>,environment-type>,image-type>,compute-type>, andservice-role>: Set your desired project configuration settings.
-
Automatically retry a build (AWS SDKs)
For more information about using AWS CodeBuild with the AWS SDKs, see the AWS SDKs and tools reference.