如何让 Jenkins 连接到 git 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19735232/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:18:19  来源:igfitidea点击:

How to get Jenkins to connect to git repository

gitsshjenkinsgitweb

提问by Classified

I'm having trouble getting Jenkins to recognize my git repo. The screenshot is below. I was told using git clone https://blah/blah.gitwill clone the repo as read-only w/o needing credentials or keys. I want to just pull the code and build it.

我无法让 Jenkins 识别我的 git 存储库。屏幕截图如下。有人告诉我使用git clone https://blah/blah.git将把 repo 克隆为只读,不需要凭据或密钥。我只想提取代码并构建它。

The funny thing is when I execute the same command from the command line, it works and files get pulled down from the repo.

有趣的是,当我从命令行执行相同的命令时,它可以工作并且文件从 repo 中拉下来。

export GIT_SSL_NO_VERIFY=true
git clone https://blah.com:8443/blah.git

When I enter the url and environment variable in Jenkins, it's says it can't connect to the repository. Does anyone know what I might need to do to get it to work? Thanks in advance for your help.

当我在 Jenkins 中输入 url 和环境变量时,它说它无法连接到存储库。有谁知道我可能需要做什么才能让它工作?在此先感谢您的帮助。

enter image description here

在此处输入图片说明

UPDATE/CLARIFICATION: The Jenkins install is under a service account, not related to any user within the company.

更新/澄清:Jenkins 安装在服务帐户下,与公司内的任何用户无关。

UPDATE#2: Here's the console output. I've sanitized it a little so i apologize if i missed something.

更新#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

回答by Classified

Thanks for everyone's suggestions, comments, and help. I think this is a plugin issue. Someone else experienced the same thing I did (original post here). If I run this command from the command line or if I enter the command in Jenkins as Build>Execute shell>Command, it works fine.

感谢大家的建议、意见和帮助。我认为这是一个插件问题。其他人经历了我所做的同样的事情(原帖在这里)。如果我从命令行运行此命令,或者我在 Jenkins 中以 Build>Execute shell>Command 的形式输入该命令,则它可以正常工作。

I have Git Client plugin = 1.4.3 and Git Plugin 1.5.0. I'll wait to see if a newer plugin fixes this.

我有 Git 客户端插件 = 1.4.3 和 Git 插件 1.5.0。我会等着看更新的插件是否解决了这个问题。