Retry builds automatically in Amazon CodeBuild - Amazon CodeBuild
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Retry builds automatically in Amazon CodeBuild

You can use the Amazon CodeBuild console, Amazon CLI, or Amazon SDKs to automatically retry your builds in Amazon 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.

Retry a build automatically (console)

  1. Open the Amazon CodeBuild console at https://console.amazonaws.cn/codesuite/codebuild/home.

  2. 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.

  3. In Environment, choose Additional configuration.

  4. Continue with the default values and then choose Create build project.

Retry a build automatically (Amazon 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>, and service-role>: Set your desired project configuration settings.

Automatically retry a build (Amazon SDKs)

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