Suppose you have some buildspec.yml file like this that build your project and upload it on some where :
build: commands: - ng build --configuration=$BUILD_ENV post_build: commands: - aws s3 rm s3://$ENV_BUCKET --recursive - aws s3 cp dist s3://$ENV_BUCKET --recursive
the Problem here is that if build step fails codebuild continue and post_build will be executed and aws s3 rm
will clean your bucket !
I had this issue in my aws codepipeline project (fortunately none-production env) and tried to fixing it.
So here is workaround:
on-failure: ABORT
just put in build step . i tried it and it works like a charm !
build: on-failure: ABORT commands: - ng build --configuration=$BUILD_ENV post_build: commands: - aws s3 rm s3://$ENV_BUCKET --recursive - aws s3 cp dist s3://$ENV_BUCKET --recursive
Second solution is to add another Deploy Stage in aws code pipeline and do deploy action (cp to s3 bucket ) at there .
Top comments (0)