Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeBuild does not upload Build Artifact to S3

I've been playing around with CodeBuild and CodePipeline recently and ran across this problem.

Once the CodeBuild finishes successfully, it should upload the build artifact to an S3 bucket. But I noticed that when I click on the View Artifacts button it just tells me that an error occured, and my S3 bucket does not have the build artifact as well.

Codebuild finished successfully

Code Build success

But clicking on the 'View Artifacts' link takes me to this error message.

S3 error message

Somehow it looks like my build Artifact was not uploaded to S3

This is my Buildspec.yaml

version: 0.2

phases:
  build:
    commands:
       - echo "Entering build"
       - npm install
       - echo "Finishing build"
like image 517
Sashi Avatar asked Dec 17 '18 04:12

Sashi


1 Answers

I figured out that I need to add the artifacts to the build spec file as well. This wasn't added to the Buildspec by default when I created the Buildspec.yaml file on codebuild.

version: 0.2

phases:
  build:
    commands:
       - npm install nodemon
       - echo "Entering build"
       - npm install
       - echo "Finishing build"
artifacts:
  files:
    - '**/*'

After adding this codebuild automatically uploads the build artifact to the S3 bucket as intended.

like image 126
Sashi Avatar answered Oct 19 '22 10:10

Sashi