1

I am really stuck with this. I have created a job in Hudson and have configured in the same way as other jobs were. My project and build deliverables exist in Git. But every time I try to build it I am getting following errors:

Cloning repository origin
$ git clone -o origin git@github.com:xyzw/myproject.git /var/lib/hudson/jobs/myjob/workspace
ERROR: Error cloning remote repo 'origin' : Could not clone git@github.com:xyzw/myproject.git
ERROR: Cause: Error performing git clone -o origin git@github.com:xyzw/myproject.git /var/lib/hudson/jobs/myjob/workspace
Command returned status code 128: Cloning into /var/lib/hudson/jobs/myjob/workspace...
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly

Trying next repository
ERROR: Could not clone repository
FATAL: Could not clone
hudson.plugins.git.GitException: Could not clone
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:763)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:702)
    at hudson.FilePath.act(FilePath.java:756)
    at hudson.FilePath.act(FilePath.java:738)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:702)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1181)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:536)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:424)
    at hudson.model.Run.run(Run.java:1374)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:467)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:145) 

in other threads, some people recommended to create a different private-public key pair by login as a jenkins user but I dont even know how to do that in my terminal. I mean I know how to use 'sudo' command to login as a diffrent user but I dont think people were suggesting to do that using sudo.

many thanks.

Ashish
  • 1,121
  • 2
  • 15
  • 25

2 Answers2

3

You probably need to set up keyless ssh access from the hudson server to the git server. To do this follow these steps:

  1. Log into the hudson system as the hudson user.
  2. From the terminal window type ssh-keygen
  3. Leave the passphrase blank
  4. Provide a filename for the private and public key pairs.
  5. Log into the git system as the git user.
  6. Copy the public key from step 4 to the git system
  7. From the terminal run the following command to add the hudson public key to the git authorized keys file. cat {public key file} >> ~/.ssh/authorized_keys. You should back up the authorized_keys file first if it already exists.
  8. Test this by going back to the hudson system and attempting to ssh {git system name}. If it worked you should be able to connect without providing a password. Then attempt to clone the repository and build again.
  9. If it doesn't work make sure to remove the key from the authorized_keys file.
rynmrtn
  • 3,371
  • 5
  • 28
  • 44
mjk
  • 541
  • 2
  • 4
  • this might sound very silly but I got confused with the very 1st step. rest of the steps looks perfect. when you say login to hudson system as a hudson user, did u mean creating a user called 'jenkins' in my machine or login to my company's hudson account through the interface and with my usual id and password. Thanks a lot for helping me out. – Ashish Jun 20 '13 at 00:36
  • On the system where hudson is installed log in as the user the hudson processes are configured to runs as. What you want to do is set it up so the the hudson processes can authenticate to the git server via keyless ssh, and to do that the account running the hudson processes needs to have the private key. – mjk Jun 20 '13 at 03:01
0

There's a known bug around the git-plugin in Jenkins.

https://issues.jenkins-ci.org/browse/JENKINS-24368

The directory locations of key files above depends on whether you are using cygwin or an installed git package (i.e. c:\program files\git). Jenkins will be writing credential files and should be independent of the slave.

rickfoosusa
  • 1,061
  • 19
  • 26