Sparse git/stash checkout for Bamboo build

Hi all,

We have a single Stash (git) repository for several artifacts that we build. The entire checkout of a single branch is 879 megabytes. However, many of our builds don't need this whole things, and some of them need only a very small part (e.g., a few files).

Is there some way to use the sparse checkout facility of git in order to check out only a single subdirectory using Bamboo (on my Stash repo)? I could then also trigger automatic builds by using the "Include/Exclude Files" option of a repo to monitor only the changed files in there.



1 answer

1 accepted

2 votes
Accepted answer

Hi Douglas,

Currently Bamboo does not support Sparse checkout for git. I've created this feature request on your behalf to have this feature added to the:

Please add your comments to that issue and become a watcher so you can be automatically updated to work on this issue.




Thanks for these details and for creating the issue in the Atlassian system. I wonder if there is a way to pass the repo credentials and other information to a custom check-out script that will then be able to do a sparse checkout instead of the built-in checkout. Any thoughts here?

Hi Douglas, This should definitely be possible, but there will be some caveats. Currently coded checkout tasks utilize a git cache hosted on Bamboo server. The code is checked out by the server and cached, then revisions are checked against that, removing the limitation of needing to create the repo each time. If you are ok with this you can work around it by creating a script that does the checkout and calling that script with the 'script task' in Bamboo build config. You'll either need to hardcode credentials in or call them with a variable in bamboo each time. You'll also need to hardcode the path and you should be able to get revisions from environmental variables. tl;dr: it can be done, but is out of scope of our support team, so if something goes awry we may not be able to help. it will require a bit of work on your end and finagling with the script to get the remote agent to perform the full checkout. Thanks! Turner

Hi Turner, Thanks for the comments. For whatever reason, it seems that the working directory for each build (i.e. each run of the script) is identical and doesn't change for each execution. So that one run sees the junk files from the previous run still there. Is that desired behavior?

I found a setting that cleans the directory after each build. Shame it doesn't clean it BEFORE each build. :)

You could probably run an inline script task at the start of the build plan before checking out the repo to clean the directory if it exists.

It is interesting. The regular workflow with Bamboo seems to keep a copy of the whole Git/Stash repository somewhere and then just use that for a local checkout. It would be much better if I could just tap into that instead of having an entire clone of the Git database here. I am not an expert on Git so I don't know how this all works, but I will have to figure out a better way.

Hi Douglas, This is what I was mentioning with Bamboo keeping a local cached copy. You'll be unable to tap into that without using the preconfigured checkout tasks or some seriously customized code/plugin. That was one of the caveats I mentioned initially. If you want to circumvent that in order to do a sparse checkout you'll forego the usefulness of that feature. Unfortunately, in this case, it seems to be one feature or the other until the improvement has been implemented. Thanks! Turner

Any update on this?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Monday in Confluence

Organizing your space just got easier - Page Tree Drag & Drop is here

Hi Community! I’m Elaine, Confluence Product Manager. You may have read my earlier post about page tree in space navigation sidebar. I'm excited to share another improvement that helps you organize ...

68 views 3 2
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you