Clone depth not applying for pull request pipelines

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

Configuring a clone depth in pipelines does not take effect for pull request pipelines.

Environment

  • Pipelines on Bitbucket Cloud

Diagnosis

No clone depth is used after configuring a clone depth in the pull request pipeline and running a build. The Build Setup logs also show that clone depth is not used.

Cause

When a pull request pipeline is triggered, Pipeline merges the destination branch into the source branch at the build setup phase. This is to mimic what the source code will be like once the Pull Request is merged. If the merge fails, the pipeline will also fail.

You can confirm that the merge is happening by expanding the Build Setup phase logs of your pipeline and looking for a merge command :

1 2 3 [...] + git merge <commit hash> --no-edit || exit $CONFLICT_EXIT_CODE [...]

The clone depth is not considered for the merge. Otherwise, the destination branch commits would not be cloned and no merge would be possible. This is the reason why the clone depth is not applied for pull request pipelines.

Solution

For other types of pipelines, the clone depth should be applied as usual.

Updated on February 25, 2025

Still need help?

The Atlassian Community is here for you.