我正在为我的
buildspec
代码构建构建 AWS
文件,但我不知道在哪个阶段需要添加 NPM
运行测试,如果测试失败,我希望构建停止。
这是我创建的
buildspec
:
version: 0.2
env:
parameter-store:
ECOSYSTEM_CONFIG: "Ecosystem-config"
ENV: "backend"
phases:
install:
runtime-versions:
nodejs: 14
commands:
- npm install
- npm install pm2 -g
- npm install nodemon -g
pre_build:
commands:
- echo $ENV > .env.dev
- echo $ECOSYSTEM_CONFIG > ecosystem.config.js
build:
commands:
- pm2 start ecosystem.config.js
artifacts:
files:
- '**/*'
cache:
paths:
- node_modules/
我期待我的
buildspec
运行,如果测试用例失败,进程就会停止。
测试命令放在哪里并不重要。相反,您可能只需要使用
on-failure: ABORT
来指示构建在测试命令失败时停止。例如,
build:
on-failure: ABORT
commands:
- npm ci