angular - AWS Codebuild for Angular Project is successful with build error
问题描述
I am running an AWS CodePipeline building Angular project and shifting it to a S3-Bucket. Simplified buildspec looks like that:
version: 0.2
phases:
install:
runtime-versions:
nodejs: 10
pre_build:
commands:
- echo Building staging profile
build:
commands:
- echo Entered the build phase for https://s3.console.aws.amazon.com/s3/buckets/<mycoolbucket> ...
- cd db
- npm install
# Build in production mode
- npm run nx -- build db-app-desktop --prod --outputHashing=all
- echo successfully finished build phase...
post_build:
commands:
- echo Entered the post_build phase...
- aws s3 sync dist/apps/db-app-desktop s3://<mycoolbucket> --delete;
- echo Successfully finished post_build phase
This works well for a successful build. But if the project has any errors, such that the build fails, CodeBuild is still showing success status. In the Codebuild log, the build ends with an Error message like that:
Error: libs/db-app-desktop/*/*/details.component.ts:1700:13 - error TS0000: Build failes by project error.
[... details ...]
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! db@0.9.2-3.0 nx: `nx "build" "db-app-desktop" "--prod" "--outputHashing=all"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the db@0.9.2-3.0 nx script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-09-23T13_55_48_300Z-debug.log
[Container] 2021/09/23 13:55:48 Running command echo successfully finished build phase...
successfully finished build phase...
[Container] 2021/09/23 13:55:48 Phase complete: BUILD State: SUCCEEDED
But the AWS console shows green lights, there is no fail notification sent. The application is not changed and remains the one from last successful build.
How does Codebuild know that the executed build fails? We have a Java Backend, where an error in build phase immediately sets the builds/codepipelines state to FAILED, which would be the apreciated behavior here as well.
解决方案
推荐阅读
- javascript - 图像未在 Testflight 中显示
- ember.js - emberjs 使用 findRecord 加载微调器
- go - 如何防止客户端因事件信号延迟而出错?
- android - 不允许嵌套事务
- node.js - 鉴于返回结果始终是加密的,我如何对我的请求进行单元测试?
- gnuplot - Gnuplot:对数轴和 dgrid3d 不能一起工作
- python - 错误:1210:执行准备好的语句的参数数量不正确
- nexus - 日志中的 Sonatype Nexus 用户角色更改
- android - 在重命名的文件中获取真正的 mime 类型
- xamarin - 以 xamarin 形式将图像插入 PDF