Mazyod
Mazyod

Reputation: 22559

Jenkins failing to fetch private repo from GitHub

I've been banging my head for hours now...

enter image description here

This error isn't budging. For the record:

  1. I tried: login jenkins in terminal, and that command displayed in red works.
  2. While logged in as jenkins, I can clone the repo without problems.
  3. The SSH keys are in place, and they show up in the ssh-add -l
  4. The known_hosts file is properly configured
  5. I already ssh'd into github.com to add it in known_hosts
  6. Replacing the "Repository URL" with a public repo https://github.com/... works.
  7. I pulled out most of my hair, and there are a few left...

What do I suspect being the problem?

When I copied the generated SSH key that I have in ~jenkins/.ssh/id_rsa.pub, I noticed that in the end of the key, it reads: root@MyComputer, not jenkins... Because I had to use sudo ssh-keygen to generate the key... Is that bad?

Here is the build log for completeness:

Started b

y user [8mha:AAAAlh+LCAAAAAAAAP9b85aBtbiIQTGjNKU4P08vOT+vOD8nVc83PyU1x6OyILUoJzMv2y+/JJUBAhiZGBgqihhk0NSjKDWzXb3RdlLBUSYGJk8GtpzUvPSSDB8G5tKinBIGIZ+sxLJE/ZzEvHT94JKizLx0a6BxUmjGOUNodHsLgAzOEgYu/dLi1CL9vNKcHACFIKlWvwAAAA==[0manonymous
Building in workspace /Users/Shared/Jenkins/Home/jobs/RTSBuilder/workspace
Checkout:workspace / /Users/Shared/Jenkins/Home/jobs/RTSBuilder/workspace - hudson.remoting.LocalChannel@210aaf84
Using strategy: Default
Cloning the remote Git repository
Cloning repository [email protected]:organization/myRepo.git
git --version
git version 1.7.12.4 (Apple Git-37)
ERROR: Error cloning remote repo 'origin' : Could not clone [email protected]:organization/myRepo.git
[8mha:AAAAWB+LCAAAAAAAAP9b85aBtbiIQSmjNKU4P08vOT+vOD8nVc8DzHWtSE4tKMnMz/PLL0ldFVf2c+b/lb5MDAwVRQxSaBqcITRIIQMEMIIUFgAAckCEiWAAAAA=[0mhudson.plugins.git.GitException: Could not clone [email protected]:organization/myRepo.git
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:248)
    at org.jenkinsci.plugins.gitclient.AbstractGitAPIImpl.clone(AbstractGitAPIImpl.java:59)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.clone(CliGitAPIImpl.java:40)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1012)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:948)
    at hudson.FilePath.act(FilePath.java:909)
    at hudson.FilePath.act(FilePath.java:882)
    at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:948)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1114)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1411)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:657)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:562)
    at hudson.model.Run.execute(Run.java:1604)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:246)
Caused by: hudson.plugins.git.GitException: Command "git clone --progress -o origin [email protected]:organization/myRepo.git /Users/Shared/Jenkins/Home/jobs/RTSBuilder/workspace" returned status code 128:
stdout: Cloning into '/Users/Shared/Jenkins/Home/jobs/RTSBuilder/workspace'...

stderr: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:873)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:851)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:40)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:246)
    ... 16 more
Trying next repository
ERROR: Could not clone repository
[8mha:AAAAWB+LCAAAAAAAAP9b85aBtbiIQSmjNKU4P08vOT+vOD8nVc8DzHWtSE4tKMnMz/PLL0ldFVf2c+b/lb5MDAwVRQxSaBqcITRIIQMEMIIUFgAAckCEiWAAAAA=[0mjava.io.IOException: Could not clone
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1025)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:948)
    at hudson.FilePath.act(FilePath.java:909)
    at hudson.FilePath.act(FilePath.java:882)
    at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:948)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1114)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1411)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:657)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:562)
    at hudson.model.Run.execute(Run.java:1604)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:246)
Finished: FAILURE

Upvotes: 1

Views: 5961

Answers (2)

Classified
Classified

Reputation: 6050

It might be a plugin issue too as found by this SO user. I kind of verified it too, although, I used https and not the git protocol. If I run

git clone https://blah.com:8443/blah.git

from a shell, it works. If I run it inside Jenkins under the

Build>Execute shell>Command, that also works. It's just when I enter that url in the

Source Code Management>Git>Repository URL box that it doesn't work.

Upvotes: 1

UnsafePointer
UnsafePointer

Reputation: 736

I solved this problem on OSX by changing Jenkins startup from launchdaemons to launchagents, hope this works for you.

Upvotes: 1

Related Questions