简体   繁体   English

AWS CodeBuild:如何强制 buildspec.yml 在出错时退出

[英]AWS CodeBuild: How to force buildspec.yml quit on error

I have a buildspec.yml consumed by AWS CodeBuild with build and post_build tasks.我有一个由 AWS CodeBuild 使用的 buildspec.yml 和 build 和 post_build 任务。 I was a bit surprised when I found out that post_build tasks are executed even if any of build commands fail.当我发现即使任何构建命令失败也会执行 post_build 任务时,我有点惊讶。

How is possible to force quit of execution if any of build commands fail?如果任何构建命令失败,如何强制退出执行?

Thanks!谢谢!

version: 0.2

env:
    variables:
        S3_BUCKET: "..."
        BUILD_ENV : "prod"

phases:
  install:
    commands:
      - echo Installing source NPM dependencies...
      - npm install
      - npm install -g @angular/cli
  build:
    commands:
      - echo Build started on `date`
      - ng build --prod --aot --source-map=false
  post_build:
    commands:
      - echo Running post_build commands on `date`

      - aws s3 sync dist s3://${S3_BUCKET} --recursive

      - aws cloudfront create-invalidation --distribution-id XXXXXXXXXXXXXX --paths '/index.html'

add this in build or any section you want将此添加到构建或您想要的任何部分

build:
on-failure: ABORT

Also this may be helpful it shows transaction state 也可能有帮助,它显示交易状态

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将环境变量传递给 AWS 代码构建的 buildspec.yml - How to pass environment variable to the buildspec.yml for AWS codebuild AWS CodeBuild buildspec.yml 以递归方式获取所有文件和子文件夹 - AWS CodeBuild buildspec.yml get all files and subfolders recursively AWS CodeBuild - BuildSpec.yml - 导出变量未解析值 - AWS CodeBuild - BuildSpec.yml - exported-variables are not resolving values 如何将环境变量添加到CodeBuild buildspec.yml? - How Do You Add Environment Variables to CodeBuild buildspec.yml? AWS Copilot 管道失败,为什么 CodeBuild 找不到 buildspec.yml? - AWS Copilot pipeline fails, why cant CodeBuild find buildspec.yml? 为什么 AWS CodeBuild buildspec.yml 支持多个构建阶段? - Why do AWS CodeBuild buildspec.yml support multiple build phases? 有没有办法在 AWS CodeBuild 的 buildspec.yml 中指定手动批准阶段? - Is there a way to specify a manual approval stage within the buildspec.yml for AWS CodeBuild? 如何使用在 Codebuild 控制台中定义的环境变量,在 buildspec.yml 中 - How to use environment variables defined in the Codebuild console, within the buildspec.yml 我们如何通过 Boto3 API 从每个代码构建项目中获取 buildspec.yml 文件的内容 - how can we get contents of a buildspec.yml file from each codebuild project through Boto3 API 如何使用 AWS CodePipeline 为 Laravel 应用程序正确创建 buildspec.yml 文件 - How do I properly create buildspec.yml file for Laravel Application using AWS CodePipeline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM