3

Alright, so I'm having some issues with my repo on github being cloned on my Hudson server which is running Fedora 8. The output is the usual error output when an error is encountered with git:

Started by user anonymous
Checkout:workspace / /home/tomcat/.hudson/jobs/CIExample/workspace - hudson.remoting.LocalChannel@3861e6
Using strategy: Default
Checkout:workspace / /home/tomcat/.hudson/jobs/CIExample/workspace - hudson.remoting.LocalChannel@3861e6
GitAPI created
Cloning the remote Git repository
Cloning repository origin
$ git clone -o origin https://mattupstate@github.com/mattupstate/CIExample.git /home/tomcat/.hudson/jobs/CIExample/workspace
ERROR: Error cloning remote repo 'origin' : Could not clone https://mattupstate@github.com/mattupstate/CIExample.git
ERROR: Cause: Error performing git clone -o origin https://mattupstate@github.com/mattupstate/CIExample.git /home/tomcat/.hudson/jobs/CIExample/workspace
Trying next repository
ERROR: Could not clone from a repository
FATAL: Could not clone
hudson.plugins.git.GitException: Could not clone
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:587)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:535)
    at hudson.FilePath.act(FilePath.java:753)
    at hudson.FilePath.act(FilePath.java:735)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:535)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1044)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:479)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:411)
    at hudson.model.Run.run(Run.java:1257)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:127)

The build doesn't hang at all like some people report. It instantly fails. Additionally, if I log into my box, switch to the tomcat user (the user running Tomcat and thus Hudson), and run this command:

git clone -o origin https://mattupstate@github.com/mattupstate/CIExample.git /home/tomcat/.hudson/jobs/CIExample/workspace

It runs with no problems and the repo is cloned. The only problem I've run into running that command manually is if the workspace folder already exits. Git doesn't like it when the local folder I want to clone to already exists. I have a feeling Hudson is creating that folder before the clone is attempted?

Any help would be appreciated.

Matt W
  • 6,078
  • 3
  • 32
  • 40
  • @VonC: Ironically, that link goes to a scraped repost of this SO question: http://stackoverflow.com/questions/2447878 – Piskvor left the building Dec 09 '10 at 21:51
  • @Piskvor: yes, I wasnt' aware at that time of those nefarious sites. But there is way now to alleviate the situation: http://meta.stackexchange.com/questions/58369/did-anyone-notice-that-tech-efreedom-com-seem-to-be-scraping-republishing-sos-po/71740#71740 and http://news.ycombinator.com/item?id=1985264 – VonC Dec 09 '10 at 21:55
  • @VonC: Ah, good stuff! Thanks for the heads-up. – Piskvor left the building Dec 09 '10 at 21:56

4 Answers4

1

I had a similar problem checking out a project from git on Hudson (v 2.2.1). I was earlier using subversion and it had existing workspace there. so when I configured Git, I checked the option, "Wipe out workspace before build" and when running the build on hudson it cleaned that existing workspace and fails immediately. I tried to run this few times and results the same.

When I unchecked "Wipe out workspace before build" the option, my next build and check out fine without any issues.

Has anyone observed this behaviour on hudson with git.

Sreeni
  • 361
  • 2
  • 10
  • I did investigated the issue: This happens only when you check out the first time and then it fails; At this point, if you look at the workspace dir, it would have created a .git folder. Running the job for the 2nd time it is successful. So if the option "wipe out workspace" is selected then it will clean out the .git folder and fails. There is more information here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=407887 – Sreeni Oct 03 '13 at 12:16
  • +1. After enabling this option, Hudson/Git plugin never recovered. Disabling the option fixed it. – user2390183 Nov 22 '13 at 15:35
0

Did you check your path when your Hudson job server execute and tries to call git commands?
See the "Gotcha" section of the Git Hudson plugin.

If you are seeing output indicating Git could not clone, something like the output below, go to to the Hudson configuration settings (not the project settings, the global ones) and change the Git path to a fully qualified path (eg. not "git" but "/usr/bin/git" or wherever your Git binary is installed).
You should also verify that the permissions are correct if you are doing a file system based clone.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Yeah, I've tried setting the git executable to its fully qualified path... $ /usr/bin/git clone -o origin https://mattupstate@github.com/mattupstate/CIExample.git /home/tomcat/.hudson/jobs/CIExample/workspace results in the same error. – Matt W Jul 06 '10 at 19:39
  • @Matt W: then try also to explicitly setup the $HOME environment variable, like in http://stackoverflow.com/questions/3188710/hudson-git-plugin-not-working-on-windows/3188786#3188786 or http://stackoverflow.com/questions/3182012/problem-with-hudson-git-gitosis-on-windows (even if those answers were for Windows, the same principle applies here) – VonC Jul 06 '10 at 19:50
  • the HOME environment variable already exists for the tomcat user. 'echo $HOME' outputs '/home/tomcat'. No problem there. Additionally, the public key files for git exist in the .ssh folder. – Matt W Jul 06 '10 at 19:58
  • @Matt W: The all point is to setup that `$HOME` environment variable within the Hudson configuration setting, instead of relying on the shell environment (just no be extra sure here: worth a try). A bit like http://stackoverflow.com/questions/2447878, where the keys were actually looked for not in the right place. – VonC Jul 06 '10 at 20:28
  • @Matt W: at least, the `$HOME` setting worked for Jako ;) http://stackoverflow.com/questions/3188710/hudson-git-plugin-not-working-on-windows/3188786#3188786 – VonC Jul 06 '10 at 20:43
0

I was unable to clone ssh://git@github.com/x/y.git but could clone git://github.com/x/y.git so I guess SSH is the problem.

Jesse Glick
  • 24,539
  • 10
  • 90
  • 112
0

I had this error with an ssh:// git URL, and the problem was that I didn't have the Hudson "SSH Plugin" installed.

timkingman
  • 121
  • 1
  • 3