checkout a directory from git by using jenkins
in the following steps i will show you how to checkout a directory from git by using jenkins.
Here iam having a repository called decodingdevops in git.
this repository has one directory called devops and some other files.
Now I will checkout only this devops directory from git by using jenkins.
go to jenkins
create job
When you are configuring job you can see source code management section.
Select git and enter your git clone url and enter your branch and give your git repository credentials.
checkout a directory from git by using jenkins
and in the below section you can see additional Behaviors in source code management section click on the add.
and scroll down you can see sparse checkout paths click on sparse checkout paths.
now one new small window is added.
You can see path option here enter your path of a directory.
Here i entered devops.
and save it.
Now build the job you can see in the workspace I got only devops directory.
We will not get any other remaining files from git repository to jenkins workspace.
checkout a subdirectory from git by using jenkins
let us assume that in the git repository i have directory called devops, in that i have xyz1 sub directory and in that i have xyz2 subdirectory.
devops/xyz1/xyz2
So now i want to checkout this xyz2 subdirectory.
Enter devops/xyz1/xyz2 in sparse checkout paths. save the job and build job,
So this will checkout only subdirectory xyz2.
If you want to checkout a perticular subdirectory, you have to enter path up to that that subdirectory.
HI,
IF i want to oly files rather than directory.
how can we achieve it .
let say devops dir inside it i have 2 files so whiles cloning i shld get that 2 files not devops directory.Is that possible?
Incase of i have two subdirs,
devops/xyz1/xyz2
abc/devops
and i mention sparse checkout path as devops
it checkout both these directories
I want to limit it to checkout devops/xyz1/xyz2
What can I do?