小编典典

Jenkins使用github返回了状态码128

jenkins

使用GitHub命令,我可以:

ssh -T git@github.com
Hi (MyName)! You've successfully authenticated, but GitHub does not provide shell access.

我与GitHub的连接正常(没问题),但是与Jenkins的连接出现此错误:

ERROR: Error cloning remote repo 'origin' : Could not clone git@github.com:Name-MysRepo/MyRepo.git
hudson.plugins.git.GitException: Could not clone git@github.com: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 git@github.com: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

公钥有这个问题吗?

JenkinsTomcat 7/ 下使用Ubuntu 12


阅读 910

收藏
2020-07-25

共1个答案

小编典典

这个错误:

stderr:权限被拒绝(公钥)。致命:远端意外挂断

表示Jenkins尝试使用错误的ssh密钥连接到github。

你应该:

  1. 确定jenkins的运行用户,例如。’build’或’jenkins’
  2. 在尝试执行克隆的jenkins主机上登录-即,如果节点实际上在进行构建,则不要登录到主服务器。
  3. 尝试使用ssh到github-如果失败,则需要将适当的密钥添加到/.ssh
2020-07-25