最近在学习搭建Jenkins,配置好环境后,构建的时候,老提示错误如下:
Cloning the remote Git repository Cloning repository origin ERROR: Error cloning remote repo 'origin' : Could not clone git@github.com:cherry-zhang/game-of-life.git hudson.plugins.git.GitException: Could not clone git@github.com:cherry-zhang/game-of-life.git at hudson.plugins.git.GitAPI.clone(GitAPI.java:251) at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1122) 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:1248) 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:1488) 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: hudson.plugins.git.GitException: Command "D:\install\Git\bin\git.exe clone --progress -o origin git@github.com:cherry-zhang/game-of-life.git E:\Learnings\Jenkins\workspace\gamelife-default" returned status code 128: stdout: Cloning into E:\Learnings\Jenkins\workspace\gamelife-default...
stderr: Permission denied (publickey). fatal: The remote end hung up unexpectedly at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:818)
但是直接用git命令行,完全是ok的。
搜索尝试了所有答案后,问题解决如下:
在jenkins中,把git的设置由git.exe改成git.cmd即可。