Bitbucket Pipelines build setup is running longer than expected

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

Summary

This article will help diagnose and solve scenarios when a Bitbucket Pipelines build setup runs longer than expected.

Cause

The build setup time includes, among other things, the time needed to pull a step's Docker image (steps running on Atlassian's infrastructure or with a self-hosted Linux Docker runner) and the time needed to clone the repo. Possible causes for this issue are:

  • The repository size may be large.

  • If your Pipelines step runs on Atlassian's infrastructure or with a self-hosted Linux Docker runner, the Docker image used as the step's build container may be large.

    • This is not applicable to steps running with a self-hosted Linux Shell, MacOS, or Windows runner, as these types of runners don't use Docker containers and the builds run directly on the host machine.

Solution

If you observe that cloning the repo locally and pulling the Docker image locally (steps running on Atlassian's infrastructure or with a self-hosted Linux Docker runner) takes similar time to your step's Build setup:

  • If your repo has large files that do not need to be versioned, consider rewriting history to remove these large files.

  • You can configure a smaller depthfor your Pipelines step.

    • Please keep in mind that this is not applicable to pull-requests builds or builds triggered on commits. These builds always perform a full clone, so they can merge the PR or check out the commit, respectively.

  • If the Docker image you use as a build container is large and you own this image, you can try reducing its size.

  • If the Docker image you use as a build container is large and it is a third-party image, you can create your own Docker image. The article on reducing the image's size has tips on how to keep the image size small.

If you observe that cloning the repo locally and pulling the Docker image locally (steps running on Atlassian's infrastructure or with a self-hosted Linux Docker runner) is a lot faster than your step's Build setup, raise a Support Ticket and share the Pipeline build URL from bitbucket.org.

Diagnosis

If you're unsure of the cause of a slow running build, follow these diagnostic steps to narrow down the root cause.

Repository size

Clone the repository locally and observe if the time taken is similar to the time it takes to clone the repo in a Pipelines build. We provide sample clone commands below based on the type of build. In these commands, you'll need to replace:

  • branch-name with the name of the branch or tag that the step is running for. For a pull-requests build, replace it with the name of the PR's source branch.

  • 50 with the depth your step is using, if you have configured a different depth for this step in your bitbucket-pipelines.yml.

  • username with the username of your Bitbucket account, that you can find here https://bitbucket.org/account/settings/ (you will also need an app password for authentication, that you can generate here https://bitbucket.org/account/settings/app-passwords/)

  • my-workspace and my-repo with the workspace id and repo slug for your repo.

Sample clone commands:

  • If your Pipelines step runs on a branch or on a tag, you can use the command:

    • git clone --branch="branch-name" --depth 50 https://username@bitbucket.org/my-workspace/my-repo.git

  • If your Pipelines step runs on a pull request, you can use the command:

    • git clone --branch="branch-name" https://username@bitbucket.org/my-workspace/my-repo.git

  • If your Pipelines step runs on a specific commit, you can use the command:

    • git clone -n https://username@bitbucket.org/my-workspace/my-repo.git

Docker image size

This is only applicable to Pipelines steps running on Atlassian's infrastructure or with a self-hosted Linux Docker runner. These steps run in Docker containers based on the image you have specified in your bitbucket-pipelines.yml file.

You need to have Docker installed on your computer to perform the following steps.

  1. Open the repository on Bitbucket's website.

  2. Select Pipelines from the left sidebar.

  3. Select from the list of builds a build whose setup is taking a long time.

  4. On the build's page, select the step whose setup is taking a long time.

  5. Expand the Build setup section in the build log.

  6. Look for the text Images used in the Build setup. You will see something like the following:

    • Images used: build : docker.io/atlassian/defaultimage@sha256:689e2c63e20a48e0a4d31156adcf32b4474dc32b50ab05abe3682b39fb9767a8

    • If your step is using services, you will see additional images listed.

  7. Copy the URL of each image listed there, in our example it is:

    • docker.io/atlassian/defaultimage@sha256:689e2c63e20a48e0a4d31156adcf32b4474dc32b50ab05abe3682b39fb9767a8

  8. Pull the image on your computer by running the following command

    • docker pull docker.io/atlassian/defaultimage@sha256:689e2c63e20a48e0a4d31156adcf32b4474dc32b50ab05abe3682b39fb9767a8

  9. Observe if the time taken to pull the Docker image locally and clone the repo locally is similar to the time of your Pipelines step's Build setup.

Updated on September 25, 2025

Still need help?

The Atlassian Community is here for you.