0

I have the following excerpt from a buildspec.yml file:

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

When I run this CodeBuild stand alone, both the primary and secondary artifacts are uploaded to 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

When run through CodePipeline, only the secondary artifacts are uploaded!

[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 is configured to run parallel build actions running the same CodeBuild

1 Answer 1

1

Found a workaround: Specify both artifacts as secondary in the CodeBuild config and the buildspec.

artifacts:
  secondary-artifacts:
    artifact1:
      base-directory: $CODEBUILD_SRC_DIR
      files:
        - source1_file
    artifact2:
      base-directory: $CODEBUILD_SRC_DIR_source2
      files:
        - source2_file

The names need to match those in the CodeBuild's Artifacts configuration - use the Add Artifact button to add further secondary artifacts.

Sign up to request clarification or add additional context in comments.

1 Comment

The hint of the name of Project's Artifacts really helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.