1
0

More than 3 years have passed since last update.

bitbucketのpipelinesでgit describeでエラーにならないようにする

Posted at

はじめに

普段 kotlin で開発しているのですが、ビルドに時間がかかって困っています。
なので、bitbucketのpipelinesで自動的にbuildして、s3に上げて、それを使おうとしたのですが、tagを付けてもgit describeがpipelines上ではエラーになってしまいます。
ローカル環境ではエラーにならないのに全然理由がわからずに困っていたのですが、やっと解決したので共有します。

git describeでエラーになる理由

pipelinesのBuld setupに秘密がありました。

ログをみると以下のようになっているかと思います。

+ umask 000
+ GIT_LFS_SKIP_SMUDGE=1 retry 6 git clone --branch="master" --depth 50 https://x-token-auth:$REPOSITORY_OAUTH_ACCESS_TOKEN@bitbucket.org/$BITBUCKET_REPO_FULL_NAME.git $BUILD_DIR
Cloning into '/opt/atlassian/pipelines/agent/build'...

--depth 50を指定していることにより、タグを付けたところまでcloneしてくれないのが原因でした。

どうすれば

--depth 50を指定しなければよいので、cloneのオプションを指定します。

bitbucket-pipelines.yml
image: build用docker-image

clone:
  depth: full

pipelines:
  以下略

これで無事にtagを付けたcommitもcloneされます。

+ umask 000
+ GIT_LFS_SKIP_SMUDGE=1 retry 6 git clone --branch="master" https://x-token-auth:$REPOSITORY_OAUTH_ACCESS_TOKEN@bitbucket.org/$BITBUCKET_REPO_FULL_NAME.git $BUILD_DIR
Cloning into '/opt/atlassian/pipelines/agent/build'...

参考

1
0
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
1
0