在jenkins配置git,如下:
配置好之后,点击立即构建,等了很久出现如下错误:
ERROR: Error fetching remote repo 'origin' hudson.plugins.git.GitException: Failed to fetch from liyuanhong@localhost:/Users/liyuanhong/project/git_repro/crashTest.git at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:806) at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1070) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1101) at hudson.scm.SCM.checkout(SCM.java:495) at hudson.model.AbstractProject.checkout(AbstractProject.java:1278) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529) at hudson.model.Run.execute(Run.java:1728) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:404) Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress liyuanhong@localhost:/Users/liyuanhong/project/git_repro/crashTest.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: Permission denied, please try again. packet_write_wait: Connection to ::1 port 22: Broken pipe 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:1793) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1519) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:64) at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:315) at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:804) ... 11 more ERROR: null Finished: FAILURE
后来发现在启动jenkins的终端里面出现如下信息:
Enter passphrase for key ‘/var/folders/vy/9r15p_192llf0sp092b3dzxw0000gn/T/ssh8620142580683014197key’: Enter passphrase for key ‘/var/folders/vy/9r15p_192llf0sp092b3dzxw0000gn/T/ssh8348919029967460681key’: Enter passphrase for key ‘/var/folders/vy/9r15p_192llf0sp092b3dzxw0000gn/T/ssh8676457670984005808key’:
解决方法,进入用户主目录的里的 .ssh 目录,新建一个authorized_keys 文件;把jenkins配置用户的公钥粘贴进去,再次点击构建,构建成功
版权声明:本文为lyhDream原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。