1

I have very large repository in Git and I have created a job in Jenkins that checks out just one sub-folder from the project following this steps Jenkins and Git sparse checkouts. The problem is that when i or some of my colleagues Wipe Out Current Workspace from Jenkins, info/sparse-checkout gets deleted too.

How can i fix this issue without having to create info/sparse-checkout every time for the same job?

Community
  • 1
  • 1
user3198761
  • 11
  • 1
  • 4
  • 1
    when you wipe the WS, it deletes the .git folder. And this is the folder that holds the file for the sparse checkout ".git/info/sparse-checkout" – OK999 Mar 07 '17 at 20:06

2 Answers2

2

According to this Jenkins support ticket it's a recent addition. As I am currently working through this I will try to remember to update on my progress.

[edit] To clarify - Git Sparse Checkout in Jenkins is apparently supported via Jenkins Plugin as of 31/Mar/14. I have no experience with this plugin to say that it works. However, I am hoping to add this plugin to our Jenkins system soon and report back on its success.

  • Please provide a definite answer. – ElectronicGeek May 14 '14 at 15:27
  • 2
    @ElectronicGeek - The individual was trying to find a way take advantage of sparse checkout with Git inside of Jenkins because the "workaround" presented in another stack overflow article was not working for him. I gave him a link to the Jenkins ticket that provides the recently completed implementation of a Jenkins plugin that does exactly that. My comment afterwards was meant to imply that I have no personal experience that the plugin works as advertised and that I am currently trying to use it as well. Sorry I was unclear. – bakerhillpins May 15 '14 at 18:31
  • Thanks. Try not to post answers if it doesn't solve the question, it's not really an answer, then. – ElectronicGeek May 15 '14 at 18:46
  • 2
    @ElectronicGeek: It does solve the problem, what isn't clear about that? He can install the newly developed Jenkins plugin that properly supports Git sparse checkout. Problem solved. – bakerhillpins May 16 '14 at 20:35
0

I think it is currently not possible with the git plugin alone (maybe you extend it).

I see these two possible solutions:

  • You use a plugin (EnvInject+Plugin or pre-scm-buildstep) to execute a shell-script before the SCM checkout. The script have to look like apenwarrs answer.

  • You have a task in Ant/Maven/Grunt/Whatever, which setup the sparse checkout (what I currently do). Setup your Job as usally and execute the new task before all others.

Community
  • 1
  • 1
weemonger
  • 146
  • 1
  • 8