Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jenkins git clone: can't clone to a specific directory

Tags:

git

jenkins

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.

like image 781
noamtm Avatar asked Dec 18 '14 12:12

noamtm


People also ask

How do I clone a git repository to a specific directory in Jenkins?

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] .

Can I git clone in a specific folder?

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.

How do I copy a repository to a specific folder?

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 .

Is it possible to clone a git repository in Jenkins?

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.


1 Answers

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.

like image 180
noamtm Avatar answered Nov 14 '22 23:11

noamtm