概要
ローカルでcircleci build
コマンドを使って設定ファイルを確認しようとしたところ、エラーでタスクが正常終了しない。
console
====>> Checkout code
#!/bin/sh -eo pipefail
mkdir -p /root/project && cd /tmp/_circleci_local_build_repo && git ls-files | tar -T - -c | tar -x -C /root/project && cp -a /tmp/_circleci_local_build_repo/.git /root/project
/bin/sh: git: not found
tar: empty archive
tar: short read
Error: Exited with code 1
Step failed
Error: runner failed (exited with 101)
Task failed
Error: task failed
実行したconfig.ymlは下記の通り。
config.yml
version: 2
jobs:
build:
docker:
- image: node:12.13.0-alpine
steps:
- checkout
- run:
name: Greeting
command: echo Hello, world.
- run:
name: Print the Current Time
command: date
原因
コンソールにも出力されているように、checkout時、コンテナ上でgitが実行できないことが原因。
今回使用しているimage:node:12.13.0-alpine
には
gitはデフォルトでは入っていない。
対応
checkout実行前に、apkコマンドでgitを用意してあげる。
config.yml
version: 2
jobs:
build:
docker:
- image: node:12.13.0-alpine
steps:
- run:
name: add git
command: apk -U add git
- checkout
- run:
name: Greeting
command: echo Hello, world.
- run:
name: Print the Current Time
command: date
実行結果は以下の通り
console
====>> Checkout code
#!/bin/sh -eo pipefail
mkdir -p /root/project && cd /tmp/_circleci_local_build_repo && git ls-files | tar -T - -c | tar -x -C /root/project && cp -a /tmp/_circleci_local_build_repo/.git /root/project
====>> Greeting
#!/bin/sh -eo pipefail
echo Hello, world.
Hello, world.
====>> Print the Current Time
#!/bin/sh -eo pipefail
date
Sun Dec 1 12:48:31 UTC 2019
Success!
無事、実行されました。