【发布时间】:2020-05-27 16:25:41
【问题描述】:
我正在尝试使用 Git 插件在 Jenkins 中配置一个 Git 项目。在项目配置页面中,我在 Git 配置中输入存储库 URL,即 https URL (https://git.mycompany.com/git/MyProject.git)。但是,当我构建项目时,出现以下错误:
Started by user Hudson Administrator
[EnvInject] - Loading node environment variables.
Building in workspace /home/hudson/.hudson/jobs/MyProject/workspace
Checkout:workspace / /home/hudson/.hudson/jobs/MyProject/workspace - hudson.remoting.LocalChannel@3699cfcc
Using strategy: Default
Cloning the remote Git repository
Cloning repository https://git.mycompany.com/git/MyProject.git
git --version
git version 1.8.2.1
ERROR: Error cloning remote repo 'origin' : Could not clone https://git.mycompany.com/git/MyProject.git
hudson.plugins.git.GitException: Could not clone https://git.mycompany.com/git/MyProject.git
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:286)
at org.jenkinsci.plugins.gitclient.AbstractGitAPIImpl.clone(AbstractGitAPIImpl.java:59)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.clone(CliGitAPIImpl.java:47)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1012)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:948)
at hudson.FilePath.act(FilePath.java:912)
at hudson.FilePath.act(FilePath.java:885)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:948)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1114)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1411)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:652)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:557)
at hudson.model.Run.execute(Run.java:1665)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:507)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:230)
Caused by: hudson.plugins.git.GitException: Failed to connect to https://git.mycompany.com/git/MyProject.git
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.getURLWithCrendentials(CliGitAPIImpl.java:1374)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.getURLWithCrendentials(CliGitAPIImpl.java:1326)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:47)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:280)
... 16 more
Trying next repository
ERROR: Could not clone repository
java.io.IOException: Could not clone
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1025)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:948)
at hudson.FilePath.act(FilePath.java:912)
at hudson.FilePath.act(FilePath.java:885)
at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:948)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1114)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1411)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:652)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:557)
at hudson.model.Run.execute(Run.java:1665)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:507)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:230)
我可以从命令行克隆存储库,也可以在 Jenkins 项目预构建步骤中将 git clone 作为 shell 命令执行,所以我不知道为什么插件配置不起作用.认为这可能是身份验证问题,我尝试在 .netrc 文件中指定凭据,并将它们包含在 URL 中(即https://username:password@git.mycompany.com/git/MyProject.git),但在所有情况下我仍然遇到相同的错误。有什么想法吗?
【问题讨论】:
-
一个可能的原因是 Jenkins 无法接受您的 ssl 证书(可能不是您使用的域)
-
确实我目前的SSL证书有问题,这就是我在全局.gitconfig中添加sslVeridy=false的原因。詹金斯没有考虑到这一点吗?有不同的配置吗?
-
由于 Jenkins 是用 Java 编写的,它使用 Java 的接受证书列表,所以也许你只需要将它添加到该存储中。这里有一些解决方法:mkyong.com/webservices/jax-ws/…
-
我看到了同样的问题。这是 jenkins git 插件中的一个错误。当您在 jenkins 配置中设置使用 JGit 时,您可以让它工作。或者使用 SSH。它在以前的版本中工作(几个月前)。
-
@jimpic 看来毕竟是这样。我还测试了对公共 Git 存储库的访问(以确保我传递凭据的方式没有问题),但它仍然没有工作,所以我想剩下的唯一选择是插件的错误。如果您将此作为答案发布(可能会提供有关可能解决方法的更多详细信息),我将很乐意接受。
标签: git jenkins jenkins-plugins