git clone fails on Hudson on Mac OS X

I am using Hudson with git plugin on Mac OS X. My git repository is on my own server and is accessible with SSH. I have keys configured properly. I am starting Hudson from command line using the default Winstone server. Cloning from command line works and everything worked very well from Hudson before one day I wanted to force Hudson to clear the repository before the build. And so I checked the Clean workspace before build in the Advanced Project Options group. From now on, every single build fails with the following message:

Started by user anonymous
Cleaning the workspace because project is configured to clean the workspace before each build.
Checkout:workspace / /Users/mczenko/.hudson/jobs/My Project/workspace - hudson.remoting.LocalChannel@592e4ff9
Using strategy: Default
Last Built Revision: Revision fc233689562bf464b08d7406a382d4bee0209c04 (origin/master)
Checkout:workspace / /Users/user/.hudson/jobs/My Project/workspace - hudson.remoting.LocalChannel@592e4ff9
Cloning the remote Git repository
Cloning repository origin
ERROR: Error cloning remote repo 'origin' : Could not clone git@myserver.com:git/MyProject.git
ERROR: Cause: Exception caught during execution of fetch command
Trying next repository
ERROR: Could not clone repository
FATAL: Could not clone
hudson.plugins.git.GitException: Could not clone
    at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:913)
    at hudson.plugins.git.GitSCM$3.invoke(GitSCM.java:845)
    at hudson.FilePath.act(FilePath.java:758)
    at hudson.FilePath.act(FilePath.java:740)
    at hudson.plugins.git.GitSCM.gerRevisionToBuild(GitSCM.java:845)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:622)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1483)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:507)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:424)
    at hudson.model.Run.run(Run.java:1366)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:145)

Initially I thought something is wrong with my ssh configuration and that maybe there is something specific to my server installation. But then I checked the same with one of my GitHub repositories and the problems persists. There are many similar questions related to this problem, most of them referring to configuration of ssh – which turns out to be done correctly on my system. I also found the message at http://wiki.hudson-ci.org/display/HUDSON/Git+Plugin suggesting that this failure may be caused by a problem with the path to the git executable. I checked that of course and as expected it makes no difference on my system. Even closer problem is reported here: Hudson git clone error where Rob Segal says:

  • How do I force Git to use the owner and permissions of the enclosing folder?
  • git rebase --continue won't work
  • How to delete some files from my commit
  • Git-svn: create & push a new branch/tag?
  • What is the purpose of git merge's rebase option?
  • Gitlab refuses to create remote repositories
  • This is exactly the problem I have been running into. If I do a clone on command line first into the workspace where hudson will be working future builds work fine. Something is clearly going on wrong with the initial cloning process but I can’t say what exactly at this point. No doubt debugging the Git plugin code could reveal exactly what is wrong. If I ever get some free time I plan to do this.

    I haven’t found so far any reference to the situation I have, where the failure in clone seems to be correlated with enabling Clean workspace before build option.

    Git plugin has its own option Wipe out workspace before build, which seems to have the same function as the Clean workspace before build option mentioned above. It has the same effect on cloning: after enabling it, cloning fails with the message above.

    Once I noticed the problem, the work around seems to be not to use the Clean workspace before build option and not to use git plugin for fresh builds (and doing git clone in the build step), but I am not sure if this is really the problem. Maybe someone has the same problem and can point out some solution.

  • Git ignore subfolder
  • GitHub clone repositories with SSH doesn't work
  • Git: Error creating pull request: Forbidden (HTTP 403)
  • Git rebasing not working correctly?
  • How to find the latest commits in one git repository?
  • How to download/clone a new branch from my server git repository into an already created local git repository in my PC with Eclipse EGit
  • One Solution collect form web for “git clone fails on Hudson on Mac OS X”

    Remember that the hudson/jenkins user will be making the clone request. You’ll need to have
    configured an ssh key for the user running hudson, and given that user read access to the repository.

    Git Baby is a git and github fan, let's start git clone.