git Jenkins 在从 gitHub 克隆时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12202078/
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-10 14:28:35  来源:igfitidea点击:

Jenkins giving error while cloning from gitHub

gitgithubjenkins

提问by Sagar

I am new to Jenkins, I am getting following error while cloning repository from GitHub.

我是新手Jenkins,从GitHub.

I tried to search all relevant issues here but could find exact stacktstrace with answers.

我试图在这里搜索所有相关问题,但可以找到带有答案的确切 stacktstrace。

I am trying to clone repository which requires username and password, I am providing SSH://repository-path in job configuration settings for my job. I have not done any .ssh related settings yet as this seems to be different problem than security issue with GIT repository.

我正在尝试克隆需要用户名和密码的SSH://存储库,我在我的作业的作业配置设置中提供存储库路径。我还没有做任何与 .ssh 相关的设置,因为这似乎与 GIT 存储库的安全问题不同。

I couldn't figure out what comment Jenkins is trying to execute, which file/directory it is not finding clueless.

我无法弄清楚詹金斯试图执行什么评论,它没有发现哪个文件/目录毫无头绪。

Here is my exact stack trace from Jenkins job:

这是我从 Jenkins 工作中得到的确切堆栈跟踪:

Caused by: java.io.IOException: Cannot run program: Error trying to determine the git version: Error performing command: --version Assuming 1.6 ERROR: Error cloning remote repo 'myRE' : Could not clone [email protected]:myORG/RVL.myProj.git hudson.plugins.git.GitException: Could not clone [email protected]:myORG/RVL.myProj.git at hudson.plugins.git.GitAPI.clone(GitAPI.java:268) at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1122) at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1064) at hudson.FilePath.act(FilePath.java:842) at hudson.FilePath.act(FilePath.java:824) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1064) at hudson.model.AbstractProject.checkout(AbstractProject.java:1256) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:589) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:494) at hudson.model.Run.execute(Run.java:1502) at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:477) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:236) Caused by: hudson.plugins.git.GitException: Error performing command: clone -o RVL.myProj [email protected]:myORG/RVL.myProj.git /var/lib/jenkins/jobs/myProj/workspace at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:862) at hudson.plugins.git.GitAPI.access$000(GitAPI.java:40) at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:264) at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:244) at hudson.FilePath.act(FilePath.java:842) at hudson.FilePath.act(FilePath.java:824) at hudson.plugins.git.GitAPI.clone(GitAPI.java:244) ... 13 more Caused by: java.io.IOException: Cannot run program "": error=2, No such file or directory at java.lang.ProcessBuilder.start(Unknown Source) at hudson.Proc$LocalProc.(Proc.java:244) at hudson.Proc$LocalProc.(Proc.java:216) at hudson.Launcher$LocalLauncher.launch(Launcher.java:709) at hudson.Launcher$ProcStarter.start(Launcher.java:338) at hudson.Launcher$ProcStarter.join(Launcher.java:345) at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:843) ... 19 more Caused by: java.io.IOException: error=2, No such file or directory at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.(Unknown Source) at java.lang.Pro

引起:java.io.IOException:无法运行程序:尝试确定 git 版本时出错:执行命令时出错:--version 假设 1.6 错误:克隆远程存储库“myRE”时出错:无法克隆 [email protected]:myORG /RVL.myProj.git hudson.plugins.git.GitException:无法在 hudson.plugins.git.GitAPI.clone(GitAPI.java:268) 克隆 [email protected]:myORG/RVL.myProj.git。 plugins.git.GitSCM$2.invoke(GitSCM.java:1122) at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1064) at hudson.FilePath.act(FilePath.java:842) at hudson.FilePath .act(FilePath.java:824) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1064) at hudson.model.AbstractProject.checkout(AbstractProject.java:1256) at hudson.model.AbstractBuild$AbstractBuildExecution。defaultCheckout(AbstractBuild.java:589) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:494) at hudson.model.Run.execute(Run .java:1502) 在 hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:477) 在 hudson.model.ResourceController.execute(ResourceController.java:88) 在 hudson.model.Executor.run(Executor.java:236)引起:hudson.plugins.git.GitException:执行命令时出错:clone -o RVL.myProj [email protected]:myORG/RVL.myProj.git /var/lib/jenkins/jobs/myProj/workspace at hudson.plugins .git.GitAPI.launchCommandIn(GitAPI.java:862) 在 hudson.plugins.git.GitAPI.access$000(GitAPI.java:40) 在 hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:264) at hudson.plugins.git.GitAPI$1.invoke(GitAPI.java:244) at hudson.FilePath.act(FilePath.java:842) at hudson.FilePath.act(FilePath.java:824) at hudson.plugins .git.GitAPI.clone(GitAPI.java:244) ... 13 更多 引起:java.io.IOException:无法运行程序“”:错误=2,在 hudson.Proc$LocalProc.(Proc.java:244) 的 java.lang.ProcessBuilder.start(Unknown Source) 中没有这样的文件或目录在 hudson.Proc$LocalProc.(Proc.java:216) 在 hudson.Launcher$LocalLauncher.launch(Launcher.java:709) 在 hudson.Launcher$ProcStarter.start(Launcher.java:338) 在 hudson.Launcher$ProcStarter .join(Launcher.java:345) at hudson.plugins.git.GitAPI.launchCommandIn(GitAPI.java:843) ... 19 更多 原因:java.io.IOException: error=2, No such file or directory at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.(Unknown Source) at java.lang.Pro

回答by superlee

I encountered and fixed the same problem :)

我遇到并解决了同样的问题:)

There are two way to configure the path of git:

配置git的路径有两种方式:

  1. On Jenkins Master

    a. Enter Jenkins System Configure (Jenkins -> Manage Jenkins -> Configure System )

    b. Find the Git item and Configure the git installation (specify the git path on Jenkins Master)

  2. On Jenkins Slave

    a. Enter Jenkins Slave's Configure

    b. Check the "Tool Locations" Checkbox and specify the path of git on the Jenkins Slave.

  1. 关于詹金斯大师

    一种。进入 Jenkins 系统配置(Jenkins -> 管理 Jenkins -> 配置系统)

    湾 找到Git项并配置git安装(在Jenkins Master上指定git路径)

  2. 关于詹金斯奴隶

    一种。进入Jenkins Slave的Configure

    湾 勾选“工具位置”复选框并指定 Jenkins Slave 上的 git 路径。

In my situation, I don't have the privilege to access the Jenkins Master. So I install the git on the Jenkins Slave and add it to Jenkins Slave's Configure.

在我的情况下,我没有访问 Jenkins Master 的权限。所以我在 Jenkins Slave 上安装了 git 并将其添加到 Jenkins Slave 的配置中。

回答by Martin

This seems to be a bug, see JENKINS-16523where I posted a workaround.

这似乎是一个错误,请参阅我发布了解决方法的JENKINS-16523

回答by kayn

I went through the same issue.

我经历了同样的问题。

I noticed the mixture of git configuration in individual jobs "/var/lib/jenkins/jobs/job_name/config.xml":

我注意到在单个作业“/var/lib/jenkins/jobs/job_name/config.xml”中混合了 git 配置:

[[email protected] jobs]# find . -maxdepth 2 -name     config.xml|xargs grep '<gitTool>'
./job1/config.xml:    <gitTool>git</gitTool>
./job2/config.xml:    <gitTool>Default</gitTool>
./job3/config.xml:    <gitTool>git</gitTool>
./job4/config.xml:    <gitTool>Default</gitTool>

So I fixed the name of gitTool and restarted the Jenkins. It looks like the git configuration doesn't properly and the change of git is not propagated to all jobs.

所以我修复了 gitTool 的名称并重新启动了 Jenkins。看起来 git 配置不正确,并且 git 的更改没有传播到所有作业。

Also be aware that the git configuration can differ in .xml file with configuration and the configuration in webface of the Jenkins!!!

另请注意,.xml 文件中的 git 配置可能与 Jenkins 的配置和 webface 中的配置不同!!!

回答by Ritesh

  1. Run git --versionon either Master or Slave
  2. If you do not get anything, that means Git is not installed
  3. If you think Git is installed, add path of the Git executable (e.g. C:\Program Files\Git\cmd) to the PATHenvironment variable
  4. Run git --versionon either Master or Slave and make sure that you get the valid version
  1. git --version在 Master 或 Slave 上运行
  2. 如果没有得到任何东西,则表示未安装 Git
  3. 如果您认为安装了 Git,请将 Git 可执行文件的路径(例如 C:\Program Files\Git\cmd)添加到PATH环境变量中
  4. git --version在 Master 或 Slave 上运行并确保您获得有效版本

回答by Hailin Tan

Except for step answered by superlee, you need config your node properties for your server side, the Tool Locations if your local is windows system, refer to below screenshot:

除了superlee回答的步骤,你需要为你的服务器端配置节点属性,如果你本地是windows系统,工具位置,参考下面的截图:

tool location for your server side

服务器端的工具位置

回答by Bibin Wilson

It could happen due to a variety of reasons.

它可能由于多种原因而发生。

  1. You might not have git installed
  2. Jenkins is not able to use the git binary
  3. Permission issue.
  1. 你可能没有安装 git
  2. Jenkins 无法使用 git 二进制文件
  3. 权限问题。

This blog , Jenkins Git Clone Error, explains all the scenarios of this error and its solution.

这篇博客Jenkins Git Clone Error解释了此错误的所有场景及其解决方案。

回答by Arpit Aggarwal

I came across same issue after I created a new JOB, fixed it correcting the slave name (with GITInstalled) in Label Expressionunder Restrict where this project can be run.

我遇到同样的问题来了我创建了一个新的后JOB,固定它修正了从域名(与GIT在已安装的)Label ExpressionRestrict where this project can be run