如何让Jenkins连接到git仓库

6
我在使用Jenkins识别我的Git代码库时遇到了麻烦。如下图所示。我被告知使用git clone https://blah/blah.git可以将代码克隆为只读,无需凭据或密钥。我想要拉取代码并构建它。
有趣的是,当我从命令行执行相同的命令时,它可以正常工作并从代码库中获取文件。
export GIT_SSL_NO_VERIFY=true
git clone https://blah.com:8443/blah.git

当我在Jenkins中输入URL和环境变量时,它显示无法连接到仓库。有人知道我需要做什么才能使其正常工作吗?感谢您提前的帮助。
更新/澄清:Jenkins安装在服务帐户下,与公司内任何用户无关。
更新#2: 这是控制台输出。我已经对其进行了一些消毒处理,所以如果我漏掉了什么,请见谅。
Started by user anonymous
Building in workspace /home/hduser/.jenkins/workspace/analytics
Fetching changes from the remote Git repository
Fetching upstream changes from https://blah.com:8443/blah.git
FATAL: Failed to fetch from https://blah.com:8443/blah.gitt
hudson.plugins.git.GitException: Failed to fetch from https://blah.com:8443/blah.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:612)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:836)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:861)
    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.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:246)
Caused by: hudson.plugins.git.GitException: Failed to connect to https://blah.com:8443/blah.git
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.getURLWithCrendentials(CliGitAPIImpl.java:1391)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.fetch(CliGitAPIImpl.java:167)
    at hudson.plugins.git.GitAPI.fetch(GitAPI.java:229)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:610)
    ... 10 more

通过“从命令行执行相同的命令”,我假设你的意思是类似于curl https://blah.com:8443/proj.git这样的东西? - Max Leske
@Nathan 当你说Jenkins日志时,我认为你是指作业的构建日志? - Classified
@MaxLeske 我假设Jenkins运行的是类似于我在命令行上运行的东西。我在命令行上运行的是 git clone https://blah.com:8443/proj.git,然后我会看到所有这些活动在屏幕上闪现,几秒钟后,我就可以在当前目录中看到来自Git存储库的文件了。 - Classified
哦,还请记住我是一个 Jenkins 和 Git 新手。我已经试图解决这个问题两天了,但进展很小。 - Classified
@Jenkins分类拥有系统级和作业级别的日志记录。主要我想了解更多细节是a) Jenkins实际运行了什么和B)是否有任何更多的错误信息。 - Nathan
显示剩余3条评论
1个回答

1
感谢大家的建议、评论和帮助。我认为这是一个插件问题。有其他人也经历了我所经历的(原帖在此)。如果我从命令行运行此命令,或者在Jenkins中输入命令作为构建>执行shell>命令,它可以正常工作。
我有Git客户端插件= 1.4.3和Git插件1.5.0。我将等待看看是否有更新的插件可以解决这个问题。

1
你尝试过在 Git 插件的主页(参见“陷阱”)中提到的建议了吗?建议使用完全限定路径来指定 git 可执行文件。 - eis
另外,您可以像同一页面中建议的那样测试“-Dorg.jenkinsci.plugins.gitclient.Git.useCLI=false”。 - eis
谢谢你的建议。是的,“gotcha”并没有帮助。我升级了插件,但仍然失败了,尽管现在出现了不同的错误信息。我还没有尝试你的第二条评论,但我会马上尝试。我可能会降级我的插件,以获得与之前相同的条件。希望它能正常工作。 - Classified
第二个会强制使用不同的插件,所以它应该可以使其工作,但会导致功能减少。 - eis
@eis,谢谢,但选项useCLI=false没有帮助。我通过tomcat运行它(./catalina.sh -Dblah.useCLI=false start),所以我不知道这是否有差别,但是当我运行ps -ef | grep catalina时,我确实看到了该选项,所以我认为Jenkins看到了它。 - Classified

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接