Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Code Build - report not getting generated in S3 Bucket

I am trying to create a code build project in aws. I have configured the code build project successfully and the code is getting build as well, however the test report is not getting created in specified S3 bucket, I have specified the artefacts in buildspec.yml but still the report is not getting generated. Below is my buildspec.yml file.

version: 0.1
  phases:
   install:
     commands:
       - echo Logging in to Amazon ECR...
       - npm install
   pre_build:
     commands:
       - echo nothing to do in pre-build
   build:
     commands:
       - echo Build started on `date`
       - echo Building the Server ...          
       - npm test
   post_build:
     commands:
       - echo Build completed on `date`
   artifacts:
     files:
        - buildreport.txt
     discard-paths: yes

I have also specified appropriate permission on S3 Bucket to upload/create file. Below is the build log I am getting after the successful build -

[Container] 2017/03/09 17:02:01 Phase context status code: Message: 
[Container] 2017/03/09 17:02:01 Entering phase POST_BUILD
[Container] 2017/03/09 17:02:01 Running command echo Build completed on `date`
[Container] 2017/03/09 17:02:01 Build completed on Thu Mar 9 17:02:01 UTC 2017
[Container] 2017/03/09 17:02:01 Running command echo $CODEBUILD_SRC_DIR
[Container] 2017/03/09 17:02:01 /tmp/src021393076/src
[Container] 2017/03/09 17:02:01 Phase complete: POST_BUILD Success: true
[Container] 2017/03/09 17:02:01 Phase context status code: Message: 
[Container] 2017/03/09 17:02:01 Preparing to copy artifacts
[Container] 2017/03/09 17:02:01 Expanding base directory path
[Container] 2017/03/09 17:02:01 Assembling file list
[Container] 2017/03/09 17:02:01 Expanding .
[Container] 2017/03/09 17:02:01 Found .
[Container] 2017/03/09 17:02:01 Expanding artifact file paths for base directory .
[Container] 2017/03/09 17:02:01 Assembling file list
[Container] 2017/03/09 17:02:01 Expanding my-build
[Container] 2017/03/09 17:02:01 Skipping invalid artifact path my-build
[Container] 2017/03/09 17:02:01 Phase complete: UPLOAD_ARTIFACTS Success: false
[Container] 2017/03/09 17:02:01 Phase context status code: ARTIFACT_ERROR Message: No matching artifact paths found
[Container] 2017/03/09 17:02:01 Runtime error (No matching artifact paths found)

I tried again after aligning and changing the buildspec.yml slightly as below -

version: 0.1

phases:
  install:
    commands:
      - echo Logging in to Amazon ECR...
      - npm install
  pre_build:
    commands:
      - echo nothing to do in pre-build
  build:
    commands:
      - echo Build started on `date`
      - echo Building the Server ...          
      - npm test
  post_build:
    commands:
      - echo Build completed on `date`
      - echo $CODEBUILD_SRC_DIR
artifacts:
  files: 
    - my-build

But it still fails to generate artefacts in the s3 folder.

like image 236
Jeet Avatar asked Nov 20 '25 07:11

Jeet


1 Answers

I too had this issue. Key point is that I had to specify the complete path along with file name in artifacts files where artifacts were placed after the build. Putting my buildspec file.

 version: 0.2

phases:
  install:
    runtime-versions:
      java: openjdk8
  pre_build: 
    commands:
      - echo nothing here
  build:
    commands:
      - mvn install
  post_build:
    commands:
       - echo build completed 
artifacts:
  files:
    - /root/.m2/repository/com/fun/learning/MyApplication/0.0.1-SNAPSHOT/MyApplication-0.0.1-SNAPSHOT.jar
cache:
  paths:
    -'root/.m2/**/*'
like image 108
Vikky Avatar answered Nov 22 '25 19:11

Vikky