CodePipeline 不像 CodeBuild 那样上传构建规范工件
CodePipeline does not upload buildspec artifacts like CodeBuild does
我从 buildspec.yml 文件中摘录了以下内容:
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
仅供参考 CodePipeline 配置为 运行 并行构建操作 运行 使用相同的 CodeBuild
找到解决方法:在 CodeBuild 配置和构建规范中将两个工件都指定为次要工件。
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 按钮添加更多次要工件。
我从 buildspec.yml 文件中摘录了以下内容:
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
仅供参考 CodePipeline 配置为 运行 并行构建操作 运行 使用相同的 CodeBuild
找到解决方法:在 CodeBuild 配置和构建规范中将两个工件都指定为次要工件。
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 按钮添加更多次要工件。