Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Sparse git/stash checkout for Bamboo build

Douglas Fields October 6, 2014

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.

Thanks,

Doug

2 answers

1 accepted

2 votes
Answer accepted
cbenard1
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 6, 2014

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: https://jira.atlassian.com/browse/BAM-15097

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

 

Thanks!

Turner

Douglas Fields October 7, 2014

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?

cbenard1
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 7, 2014

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

Douglas Fields October 7, 2014

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?

Douglas Fields October 7, 2014

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

John Snead October 7, 2014

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.

Douglas Fields October 7, 2014

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.

cbenard1
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 8, 2014

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

Neil Borromeo August 28, 2018

Any update on this?

0 votes
Daniel Collins May 4, 2022

8 years later, not even a word or a reply to the Jira. What's going on?

Anonymous Coward May 5, 2022

Simon says:

' If you need git sparse checkout you probably need a different VCS. Use SVN instead. Git is not for you. '

Simon out.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events