I was recently working on a project where I required only a particular folder inside a bitbucket repository to be cloned and tracked on the server. This was when I stumbled upon the sparse checkout feature that Jenkins offered. I decided to write this short post so that it might help you in case you have a similar requirement as me.
I have the following folder structure:
Here,I would like to clone and track only the survey folder highlighted above.
Here is how you can go about doing this,
1) Start off by creating a new freestyle project
2) Under the configure page, navigate to source code management section.
3) Here, click on the git option. Enter the repository URL followed by the credentials and the branch that you would like to build.
4) Now, besides the additional behaviour tab click on the Add dropdown menu, and select Sparse Checkout path option.
5) A textbox will be displayed. Here, enter the path to the folder that you would like to clone.
Go ahead and save your configuration
6) Click on Build Now.
Only the folder which was specified would be cloned and tracked on the server.
And that’s it, you successfully did a sparse checkout using Jenkins!
Feel free to ask any further queries you have.