【问题标题】:AWS Code Build - report not getting generated in S3 BucketAWS 代码构建 - 报告未在 S3 存储桶中生成
【发布时间】:2017-03-02 02:33:33
【问题描述】:

我正在尝试在 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 文件夹中生成人工制品。

【问题讨论】:

  • 您找到解决方案了吗?
  • 不,无论我在 files 参数中将什么设置为 artifacts,它都不起作用。这迫使我改用詹金斯。
  • 我在使用 imagedefinitions.json 文件时也遇到了这个错误。幸运的是,您的帖子向我展示了 $CODEBUILD_SRC_DIR 环境变量。我发现如果我将 imagedefinitions.json 文件写入 $CODEBUILD_SRC_DIR 目录,它应该会通过。我猜这是因为我将代码移出起始目录以将其放入 GOPATH 中。只是留下评论以防其他人有同样的问题。

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


【解决方案1】:

我也有这个问题。关键是我必须在构建后放置工件的工件文件中指定完整路径和文件名。放入我的 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/**/*'

【讨论】:

  • 这是一个有趣的发现,让我试试这个,并会更新帖子。感谢您的贡献。
猜你喜欢
  • 2019-01-29
  • 2018-05-05
  • 2017-10-09
  • 2020-04-29
  • 2020-03-14
  • 1970-01-01
  • 2017-10-15
  • 1970-01-01
  • 2020-05-26
相关资源
最近更新 更多