4

I'm trying to set Jenkins up for my project in my server.

I uploaded my build script in GitHub private repo. I've established a SSH key, and deployed it through GitHub.

But when I try to build, Jenkins fails to pull successfully from my private repo

here is the console output:

Started by user anonymous
Building in workspace /Users/Shared/Jenkins/Home/jobs/moai-test/workspace
Checkout:workspace / /Users/Shared/Jenkins/Home/jobs/moai-test/workspace - hudson.remoting.LocalChannel@15e6e48b
Using strategy: Default
Fetching changes from 1 remote Git repository
Fetching upstream changes from https://github.com/****/****.git
ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway
hudson.plugins.git.GitException: Error performing command: git fetch -t https://github.com/****/****.git +refs/heads/*:refs/remotes/origin/*
    at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:862)
    at hudson.plugins.git.GitAPI.launchCommand(GitAPI.java:817)
    at hudson.plugins.git.GitAPI.fetch(GitAPI.java:197)
    at hudson.plugins.git.GitAPI.fetch(GitAPI.java:1063)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:812)
    at hudson.plugins.git.GitSCM.access$100(GitSCM.java:90)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1096)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1064)
    at hudson.FilePath.act(FilePath.java:842)
    at hudson.FilePath.act(FilePath.java:824)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1064)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1256)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:589)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:494)
    at hudson.model.Run.execute(Run.java:1502)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:236)
Caused by: java.lang.InterruptedException
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:485)
    at java.lang.UNIXProcess.waitFor(UNIXProcess.java:115)
    at hudson.Proc$LocalProc.join(Proc.java:319)
    at hudson.Launcher$ProcStarter.join(Launcher.java:345)
    at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:843)
    ... 18 more
ERROR: Could not fetch from any repository
FATAL: Could not fetch from any repository
hudson.plugins.git.GitException: Could not fetch from any repository
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1103)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1064)
    at hudson.FilePath.act(FilePath.java:842)
    at hudson.FilePath.act(FilePath.java:824)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1064)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1256)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:589)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:494)
    at hudson.model.Run.execute(Run.java:1502)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:236)
Tinolover
  • 166
  • 1
  • 5
  • 19
  • Are you sure the Jenkins process is run under the user which actually has the ssh public and private key in `~user/.ssh` directory? – VonC Aug 17 '12 at 05:38
  • I'm pretty sure Jenkins is running as the user that has the private key. I have changed the jenkins configure file to run jenkins with the user that has the ssh public key. – Tinolover Aug 17 '12 at 05:53
  • Ok, just checking here. Another check: it the remote GitHub address correct (I mean, no typo in there? http://stackoverflow.com/questions/11485775/why-is-my-git-push-returning-with-fatal-error/11486595#11486595 or http://stackoverflow.com/questions/8904327/case-sensitivity-in-git/8906460#8906460) – VonC Aug 17 '12 at 05:54
  • yeah i just replaced the GitHub address with ****'s I am using the right address. – Tinolover Aug 17 '12 at 05:57
  • Ok (because a simple lowercase letter instead of an uppercase is enough to fail the all query) – VonC Aug 17 '12 at 06:00
  • You're using the https url and not the ssh url, so the .ssh keys are not being used. – Stephen Connolly Aug 17 '12 at 08:58

1 Answers1

3

Looking at your build log

Using strategy: Default
Fetching changes from 1 remote Git repository
Fetching upstream changes from https://github.com/****/****.git
ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway

You are using the HTTPS URI for the github repo.

The HTTPS URI uses username/password to authenticate and not the SSH key.

To use the SSH key you need to checkout the SSH URI instead, e.g.

git@github.com:****/****.git

And that should fix your issue.

Alternatively you could give Jenkins the username/password (though that is a bigger security risk)

Stephen Connolly
  • 13,872
  • 6
  • 41
  • 63
  • I've changed the HTTPS URI into SSH URI, and I've encountered another issue. The console output says that Host key verification failed. I'm sure I've generated id_rsa key then deployed it in github. Any ideas to fix this problem? – Tinolover Aug 20 '12 at 00:45
  • To fix this you will need to do ssh http://github.com and then answer yes at the prompt to add GitHub to the list of trusted hosts. You only need to do this once on any given machine and it will be added permanently. – CIGuy Aug 21 '12 at 01:05
  • You need to ensure that the key jenkins is using has an empty passphrase. Jenkins cannot handle keys with passphrases if I recall correctly (due to the complexities of feeding the passphrase to the program - which is trying to ensure only a real keyboard is used to enter the passphrase!) – Stephen Connolly Aug 21 '12 at 06:16
  • @Stephen Connolly: you should be able to use an passphrase protected key by pre-authorizing via an ssh-agent. it's complicated though and you need to re-authenticate on each reboot (or the like) – umläute Aug 21 '12 at 16:38
  • @umlaeute, yes in theory you should be able to do that, however some plugins use java client and others use cli clients so the net result is that some plugins will pick up the agent and others will bomb out. Best worst option is to generate a key specifically for Jenkins and ensure that key does not have a passphrase. – Stephen Connolly Aug 21 '12 at 20:58