Lesstep
Bitbucket Cloud・Pipelines・2026年11月2日に確認

Bitbucket Pipelines:浅いクローンで止まる Git のコマンド

Pipelines は、ステップの初めにリポジトリをクローンします。ブランチかタグのビルドでは、そのクローンにあるのは1つのブランチの最新50コミットだけです(Atlassian の Git クローンの動作)。ほかのブランチ、古い履歴、古いタグを使うコマンドは、次のどれかで止まります。同じ形のクローンを Git 2.53 で作って試すと、こう出ました。

fatal: ambiguous argument 'origin/main': unknown revision or path not in the working tree.
fatal: No names found, cannot describe anything.
fatal: origin/main...HEAD: no merge base
 ! [remote rejected] HEAD -> x (shallow update not allowed)

ビルドの種類ごとのクローン

ビルドの準備が遅いときの Atlassian の記事 Bitbucket Pipelines build setup is running longer than expected(英語)に、ビルドの種類ごとのクローンのコマンドの例があります。

--depth つきのクローンは、名指ししたブランチしか取りません。試したクローンでは、git branch -a にそのブランチだけが並び、remote.origin.fetch は +refs/heads/feature:refs/remotes/origin/feature でした。深さを付けないクローンには、全部のブランチがありました。

origin/main が無い

機能ブランチのビルドには origin/main がありません。git fetch origin main でも足されません。fetch の設定が狭いので、埋まるのは FETCH_HEAD だけです。置き先まで書きます。

script:
  - git fetch origin "+refs/heads/main:refs/remotes/origin/main"
  - git diff --name-only origin/main...HEAD

これに認証は要りません。ステップから自分のリポジトリへ届くよう、Pipelines は Git を localhost:29418 の自前のプロキシに向けています。Atlassian の「Failed to connect to localhost port 29418」の記事(英語)にその設定が出ています。

2つのブランチの分かれ目がクローンの届く範囲より前だと、3点の diff は「no merge base」で止まります。main と一緒に、履歴を全部取ります。

  - git fetch --unshallow origin "+refs/heads/main:refs/remotes/origin/main"

プルリクエストのビルドには、宛先のブランチがはじめからあり、名前は $BITBUCKET_PR_DESTINATION_BRANCH に入っています。

git describe と古いタグ

クローンには、その50コミットを指すタグが付いてきます。最後のタグがそれより古いと、git describe は1つも見つけられません。タグだけを取っても足りません。試すとタグは届きましたが、そのタグとビルドのコミットの間の履歴は切れたままで、Git は fatal: No tags can describe '…' と答えました。履歴とタグを一緒に取ります。

  - git fetch --unshallow --tags origin
  - git describe --tags

2019年の Atlassian Community の質問 「Shallow clone for pipelines is removing version tags」(英語)も同じで、最後のバージョンのタグから50コミットを超えると、タグの一覧が空になったと書いています。

ほかの Git のホストへの push

Atlassian の記事 Pushing to a remote git repository from a Bitbucket Pipeline build fails with error "shallow update not allowed"(英語・2025年9月26日更新)によると、Git のホストや、git push でデプロイするホスティングの中には、浅いクローンからの push を (shallow update not allowed) か (unpacker error) で断るものがあります。新しく作った bare のリポジトリも、同じように断りました。記事の直し方は、全部の履歴のクローンです。

要るステップだけ depth: full

pipelines:
  default:
    - step:
        clone:
          depth: full
        script:
          - git describe --tags

1つのステップに書けば、ほかのステップは速いクローンのままです。ファイルの一番上の clone: に書くと、全部のステップに効きます。SonarQube の Bitbucket Pipelines のページ(英語)も、スキャナーが履歴を全部見られるよう、全部の深さを求めています。

古いビルドをやり直すときも、深さが効きます。ブランチの50コミットより前のビルドは「The commit could not be found in the cloned repository. This can be caused by using force push or not having a deep enough clone」で落ちます(Atlassian の記事・英語、「We couldn't clone the repository」)。

IntelliJ IDEA で Bitbucket Pipelines を見る

Pipeline Inbox for Bitbucket Pipelines は、Lesstep が作っている JetBrains IDE(2024.1 以降)のプラグインです。Bitbucket Cloud の全部のリポジトリのパイプラインを IDE のツールウィンドウに並べ、ステップ、失敗したステップと止まったコマンド、Bitbucket が書くそばから伸びるステップのログを見せます。一覧・ステップ・ログは無料。パイプラインの実行・やり直し・停止は Pro(月 US$1.50・30日の無料試用つき)。

JetBrains Marketplace で入れる

Atlassian・Bitbucket・Bitbucket Pipelines は Atlassian の商標、SonarQube は SonarSource SA の商標、IntelliJ IDEA は JetBrains s.r.o. の商標です。このページは Atlassian・SonarSource・JetBrains のいずれとも提携しておらず、承認も受けていません。

ほかに:スケジュールしたパイプラインが動かない · 「Container 'build' failed to pull image」 · サービスに「Connection refused」(MySQL・PostgreSQL・Redis) · 「Not authorized to perform sts:AssumeRoleWithWebIdentity」(OIDC で AWS) · テストの結果が出ない · 変数が空になる · 「Host key verification failed」(SSH) · 「Cannot connect to the Docker daemon」 · 「authorization denied by plugin pipelines」(Docker) · 「Container 'docker' exceeded memory limit.」 · push したのに Pipelines が動かない · 「Container 'Build' exceeded memory limit.」 · 「Exceeded build time limit of 120 minutes」 · キャッシュが効かない · 「unexpected system error」 · 「command not found」 · サブモジュールを取ってこない · 「We couldn't clone the repository」 · 「No online runner available」 · 「No space left on device」 · 「Step exceeded processing limits」 · 次のステップにアーティファクトが無い · 前は通ったビルドが今は落ちる · Build setup に時間がかかる · ビルド時間を使い切った · 「Permission denied to update branch」 · 「You have reached your pull rate limit」(Docker Hub) · 「There is an error in your bitbucket-pipelines.yml」 · 「This pipeline was paused」(デプロイ) · Git LFS のファイルがポインターのまま届く・ステップからの LFS の push · condition: changesets で飛ばされるステップ(includePaths) · IntelliJ IDEA の Bitbucket Pipelines 用プラグインの比較 · English