LoginSignup
16
11

More than 5 years have passed since last update.

codebuild artifactがS3に上がってくれない。

Last updated at Posted at 2019-04-08

事象

[Container] 2019/04/08 07:11:19 Assembling file list
[Container] 2019/04/08 07:11:19 Expanding test.txt
[Container] 2019/04/08 07:11:19 Skipping invalid artifact path test.txt
[Container] 2019/04/08 07:11:19 Phase complete: UPLOAD_ARTIFACTS State: FAILED
[Container] 2019/04/08 07:11:19 Phase context status code: CLIENT_ERROR Message: no matching artifact paths found

Codebuildでartifactのアップロード先をS3にするも失敗。
ファイルは作られているように見えるが、ちゃんとアップロードされない。

原因

buildspec.ymlの中で別のディレクトリに移動して作業をしてたから。
どうやらデフォルトディレクトリ以外にartifactを置いてもアップロードされないみたい。

失敗する例

buildspec.yml
version: 0.2

phases:
  test:
    - mkdir -p hoge
    - cd hoge
    - echo "hoge" > test.txt

artifacts:
  files:
    - test.txt

成功する例

buildspec.yml
version: 0.2

phases:
  test:
    - DEFAULT=`pwd`
    - mkdir -p hoge
    - cd hoge
    - cd $DEFAULT
    - echo "hoge" > test.txt

artifacts:
  files:
    - test.txt

元のディレクトリに戻ってからファイルを作成したらちゃんと動いた。

デフォルトディレクトリは下記のように固定されてないので、
まず最初に取得しておく必要があり?(環境変数であるかも)

/codebuild/output/src123456789/src/github.com/[user]/[repo]

  • 2019/4/9追記

環境変数ありました。
CODEBUILD_SRC_DIR: CodeBuild がビルドに使用するディレクトリパス (例: /tmp/src123456789/src)。
https://docs.aws.amazon.com/ja_jp/codebuild/latest/userguide/build-env-ref-env-vars.html

16
11
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
11