Jenkins访问码云的私有库,遇到了以下问题,在此记录下,与君共勉之。
首先
想访问到码云,需要在Jenkins上配置码云的账号/密码
问题1,报128错误
详细信息如下
> git fetch --tags --progress https://gitee.com/xxx/xxx.git +refs/heads/*:refs/remotes/origin/* # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress https://gitee.com/xxx/xxx.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: error: RPC failed; result=6, HTTP code = 0
fatal: The remote end hung up unexpectedly
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2671)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2096)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:618)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:847)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1216)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1294)
at hudson.scm.SCM.checkout(SCM.java:540)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1215)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:645)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:517)
at hudson.model.Run.execute(Run.java:1896)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
at hudson.model.ResourceController.execute(ResourceController.java:101)
at hudson.model.Executor.run(Executor.java:442)
ERROR: Error cloning remote repo 'origin'
Finished: FAILURE
通过一顿分析排查,最终得出解决方案,需在码云上,配下Jenkins所在服务器的SSH公钥。参考下图:
问题2,解析码云地址报错
详细信息如下
stderr: fatal: unable to access 'https://gitee.com/xxx/xxx.git/': Could not resolve host: gitee.com; Unknown error
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2671)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2096)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:618)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:991)
... 11 more
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE
这个的话,只需要在电脑上ping下gitee.com的地址,看IP是多少,配到Jenkins服务器的hosts里即可。如下图