Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins returned status code 128 with github

Tags:

github

jenkins

With GitHub command I have:

ssh -T [email protected] Hi (MyName)! You've successfully authenticated, but GitHub does not provide shell access. 

My connection with GitHub is ok (no problem), but with Jenkins I have this error:

ERROR: Error cloning remote repo 'origin' : Could not clone [email protected]:Name-MysRepo/MyRepo.git hudson.plugins.git.GitException: Could not clone [email protected]:Name-MysRepo/MyRepo.git     at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.clone(CliGitAPIImpl.java:219)     at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1001)     at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:942)     at hudson.FilePath.act(FilePath.java:904)     at hudson.FilePath.act(FilePath.java:877)     at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:942)     at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1101)     at hudson.model.AbstractProject.checkout(AbstractProject.java:1369)     at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:676)     at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)     at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:581)     at hudson.model.Run.execute(Run.java:1575)     at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:477)     at hudson.model.ResourceController.execute(ResourceController.java:88)     at hudson.model.Executor.run(Executor.java:241) Caused by: hudson.plugins.git.GitException: Command "git clone --progress -o origin [email protected]:Name-MysRepo/MyRepo.git /root/.jenkins/jobs/TestKRGDAOV01/workspace" returned status code 128: stdout: Cloning into '/root/.jenkins/jobs/TestKRGDAOV01/workspace'...  stderr: Permission denied (publickey). fatal: The remote end hung up unexpectedly 

Is this problem with public key?

I use Jenkins under Tomcat 7 / Ubuntu 12.

like image 221
nizar ouerghi Avatar asked May 23 '13 18:05

nizar ouerghi


People also ask

How do I add git credentials to Jenkins?

First, we need to add a Credential option there. For that purpose, we need to click on the Manage Jenkins option. Step 2: Then, a new tab will open. There we need to click on the Manage Plugin option to add the Credential option there.


1 Answers

This error:

stderr: Permission denied (publickey). fatal: The remote end hung up unexpectedly

indicates that Jenkins is trying to connect to github with the wrong ssh key.

You should:

  1. Determine the user that jenkins runs as, eg. 'build' or 'jenkins'
  2. Login on the jenkins host that is trying to do the clone - that is, do not login to the master if a node is actually doing the build.
  3. Try you ssh to github - if it fails, then you need to add the proper key to <jenkins user home>/.ssh
like image 102
imdibiji Avatar answered Sep 20 '22 14:09

imdibiji