AWS Code Build - 报告未在S3 Bucket中生成

时间:2017-03-02 02:33:34

标签: amazon-web-services amazon-s3 aws-codebuild

我正在尝试在aws中创建代码构建项目。我已经成功配置了代码构建项目,并且代码也在构建,但是测试报告没有在指定的S3存储桶中创建,我已经在buildspec.yml中指定了人工制品,但仍然没有生成报告。以下是我的buildspec.yml文件。

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

我还在S3 Bucket上指定了上传/创建文件的相应权限。下面是我在成功构建后获得的构建日志 -

[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)

我在稍微调整和更改buildspec.yml之后再次尝试 -

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

但它仍然无法在s3文件夹中生成伪像。

1 个答案:

答案 0 :(得分:0)

我也有这个问题。关键是我必须在构建后放置工件的工件文件中指定完整路径以及文件名。放入我的buildspec文件。

 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/**/*'