问题描述
version: 0.2
phases:
install:
runtime-versions:
nodejs: 12
build:
commands:
- npm install
- cd e2e
- npm install
post_build:
commands:
- CHOKIDAR_USEPOLLING=true npm run e2e:$APP_MODULE
finally:
- FILENAME="${APP_MODULE}_out.json"
- echo ${FILENAME}
- mv .nyc_output/out.json ${FILENAME}
artifacts:
base-directory: e2e
files:
- '${FILENAME}'
secondary-artifacts:
videos:
base-directory: e2e/cypress/videos
files:
- '**/*'
当我单独运行此CodeBuild时,主要工件和辅助工件都被上载到S3。
[Container] 2020/08/16 15:18:18 Phase complete: POST_BUILD State: SUCCEEDED
[Container] 2020/08/16 15:18:18 Phase context status code: Message:
[Container] 2020/08/16 15:18:18 Expanding base directory path: e2e
[Container] 2020/08/16 15:18:18 Assembling file list
[Container] 2020/08/16 15:18:18 Expanding e2e
[Container] 2020/08/16 15:18:18 Expanding file paths for base directory e2e
[Container] 2020/08/16 15:18:18 Assembling file list
[Container] 2020/08/16 15:18:18 Expanding ${FILENAME}
[Container] 2020/08/16 15:18:18 Expanded to layout_out.json
[Container] 2020/08/16 15:18:18 Found 1 file(s)
[Container] 2020/08/16 15:18:18 Preparing to copy secondary artifacts videos
[Container] 2020/08/16 15:18:18 Expanding base directory path: e2e/cypress/videos
[Container] 2020/08/16 15:18:18 Assembling file list
[Container] 2020/08/16 15:18:18 Expanding e2e/cypress/videos
[Container] 2020/08/16 15:18:18 Expanding file paths for base directory e2e/cypress/videos
[Container] 2020/08/16 15:18:18 Assembling file list
[Container] 2020/08/16 15:18:18 Expanding **/*
[Container] 2020/08/16 15:18:18 Found 4 file(s)
[Container] 2020/08/16 15:18:19 Phase complete: UPLOAD_ARTIFACTS State: SUCCEEDED
通过CodePipeline运行时,只会上传辅助工件!
[Container] 2020/08/16 15:33:00 Uploading S3 cache...
[Container] 2020/08/16 15:34:53 Phase complete: POST_BUILD State: SUCCEEDED
[Container] 2020/08/16 15:34:53 Phase context status code: Message:
[Container] 2020/08/16 15:34:53 Preparing to copy secondary artifacts videos
[Container] 2020/08/16 15:34:53 Expanding base directory path: e2e/cypress/videos
[Container] 2020/08/16 15:34:53 Assembling file list
[Container] 2020/08/16 15:34:53 Expanding e2e/cypress/videos
[Container] 2020/08/16 15:34:53 Expanding file paths for base directory e2e/cypress/videos
[Container] 2020/08/16 15:34:53 Assembling file list
[Container] 2020/08/16 15:34:53 Expanding **/*
[Container] 2020/08/16 15:34:53 Found 4 file(s)
[Container] 2020/08/16 15:34:54 Phase complete: UPLOAD_ARTIFACTS State: SUCCEEDED
FYI CodePipeline配置为运行运行相同CodeBuild的并行构建操作
解决方法
找到了一种解决方法:在CodeBuild配置和buildspec中将两个工件都指定为辅助工件。
artifacts:
secondary-artifacts:
artifact1:
base-directory: $CODEBUILD_SRC_DIR
files:
- source1_file
artifact2:
base-directory: $CODEBUILD_SRC_DIR_source2
files:
- source2_file
名称需要与CodeBuild的 Artifacts 配置中的名称匹配-使用 Add Artifact 按钮添加更多的辅助工件。