According to documentation, posts and my memory, the jenkins Git plugin allows selecting the target subdirectory for a clone. I worked in another Jenkins instance I was managing. For some reason, in this new installation, I don't see that option. It's just not there. Git plugin is on the latest, version 2.3.1. I'm using the LTS release channel, so Jenkins itself is v1.580.2.
Either I'm missing something, or something is terribly wrong with my (new) installation.
If you first step into a subdir with the dir('subDir') step then the repo will be cloned into another sub-directory of subDir and you'll get subDir/[repo name]/[contents] .
Cloning only a subdirectory is not possible in Git. The network protocol doesn't support it, the storage format doesn't support it. Every single answer to this question always clones the whole repository. The question is a simple Yes/No question, and the answer is two characters: No.
To clone git repository into a specific folder, you can use -C <path> parameter, e.g. Although it'll still create a whatever folder on top of it, so to clone the content of the repository into current directory, use the following syntax: cd /httpdocs git clone [email protected]:whatever .
There are two ways to clone the project(repository) from Github. Create a new Jenkins job called 'Clone-with-https', move to the “Source Control Management” setting, and choose “Git” options if you cannot see the Git options that mean the 'GitHub' plugin wasn't installed in the Jenkins machine.
Mystery solved: at some point, the option to select subdirectory was moved into the all-mighty "Additional Behaviours" section.
It's called "Check out to a sub-directory".
And, unlike the old option, you can't set it per-repository (if you have a few git locations).
If you (like me) need to clone a few git repositories, each to its own directory, use the Multiple SCMs Plugin, and set each git repo as a separate scm provider.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With