Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Clone a git repo jus once

For now the bitbucket pipeline clones the repo in every step.

But is there a way of just cloning once and sharing the repo files like a cache?

Or do we have to make the repo as an artifact after cloning?

1 answer

0 votes
Patrik S Atlassian Team Dec 09, 2021

Hello Marcus,

Welcome to Atlassian Community!

Just to give you a little background, Pipelines uses a server-less infrastructure, meaning that the build containers are only provisioned on demand. When your pipeline build starts, it starts a docker container with the image that you provide on the YML file, and run the script commands that you have configured. The build setup includes the following steps :

  • Pull the docker images used by that step
  • Execute a git clone operation to copy the content of the repository
  • Download cache and artifacts if available.

That being said, since every build step runs in a separate docker container, each time a step starts it will clone the repository by default.

At this moment, if you want to use the repo folder in next steps but don't want to clone it again, the only option is by creating an artifact of the repository directory, as you mentioned.

You can also use the following alternatives to improve your build :

  • Reduce the clone depth of your repository in case you don't need older commit:
    clone:
      depth: 5       # include the last five commits, for example  
    pipelines:
      default:
        - step:
            name: Cloning
            script:
              - echo "Clone just five commits!"
  • If there are steps on your pipeline where you are not using the repository, you can disable the repository clone by using the following YML flag :
    - step:
            clone: 
              enabled: false
            script:
              - echo "test"

Hope that helps to address your questions! :)

Kind regards,

Patrik S

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

190 views 2 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you