DEV Community

Seifolah Ghaderi
Seifolah Ghaderi

Posted on

3 1

aws codebuild continues on failure

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Second solution is to add another Deploy Stage in aws code pipeline and do deploy action (cp to s3 bucket ) at there .

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more