AWS代码构建-在S3存储桶中未生成报告

问题描述 投票:3回答:1

我正在尝试在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存储桶指定了适当的权限,以上传/创建文件。以下是成功构建后获取的构建日志-

[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文件夹中生成伪像。

amazon-web-services amazon-s3 aws-codebuild
1个回答
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/**/*'
© www.soinside.com 2019 - 2024. All rights reserved.