2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CodeBuildでGithubのコミット番号を取得しようとしてもできなかった

Posted at

現象

連携しているgithubリポジトリのコミット番号を取得したいが失敗してしまう。

[Container] 2020/12/21 08:39:46 Running command IMAGE_TAG=$(git rev-parse --short HEAD)
fatal: not a git repository (or any parent up to mount point /codebuild)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

[Container] 2020/12/21 08:39:46 Command did not exit successfully IMAGE_TAG=$(git rev-parse --short HEAD) exit status 128
[Container] 2020/12/21 08:39:46 Phase complete: PRE_BUILD State: FAILED
[Container] 2020/12/21 08:39:46 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: IMAGE_TAG=$(git rev-parse --short HEAD). Reason: exit status 128

解決

CodeBuildにはデフォルトで環境変数が用意してあった。
SourceのコミットIDを利用したい場合は、CODEBUILD_RESOLVED_SOURCE_VERSIONを使えばOK!
用意されている環境変数一覧

2
2
0

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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?