詹金斯无法运行 git

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

Jenkins could not run git

gitjenkins

提问by Andreas K?berle

I've installed Jenkins on my mac (osx lion). But I couldn't get it work. This is the stacktrace I've got:

我已经在我的 mac (osx lion) 上安装了 Jenkins。但我无法让它工作。这是我得到的堆栈跟踪:

Started by user anonymous

Checkout:workspace / /Users/Shared/Jenkins/Home/jobs/test/workspace - hudson.remoting.LocalChannel@1c0a0847
Using strategy: Default
Checkout:workspace / /Users/Shared/Jenkins/Home/jobs/test/workspace - hudson.remoting.LocalChannel@1c0a0847
Cloning the remote Git repository
Cloning repository origin
Error trying to determine the git version: Error performing command: /usr/local/git/ --version
Cannot run program "/usr/local/git/" (in directory "/Users/Shared/Jenkins/Home/jobs/test/workspace"): error=13, Permission denied
Assuming 1.6
ERROR: Error cloning remote repo 'origin' : Could not clone [email protected]:iRest.git
ERROR: Cause: Error performing command: /usr/local/git/ clone -o origin [email protected]:iRest.git /Users/Shared/Jenkins/Home/jobs/test/workspace
Cannot run program "/usr/local/git/": error=13, Permission denied
Trying next repository
ERROR: Could not clone repository
FATAL: Could not clone
hudson.plugins.git.GitException: Could not clone
    at hudson.plugins.git.GitSCM.invoke(GitSCM.java:1046)
    at hudson.plugins.git.GitSCM.invoke(GitSCM.java:972)
    at hudson.FilePath.act(FilePath.java:783)
    at hudson.FilePath.act(FilePath.java:765)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:972)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1195)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:571)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:460)
    at hudson.model.Run.run(Run.java:1404)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:238)

回答by Josh Brown

The solution for me was to set the git path in the Manage Jenkins > Global Tool Configuration settings. In the Git section, I changed the Path to Git executableto /usr/local/bin/git.

我的解决方案是在 Manage Jenkins > Global Tool Configuration 设置中设置 git 路径。在 Git 部分,我将 Git 可执行文件路径更改为/usr/local/bin/git.

Global Tool Configuration

全局工具配置

回答by AlekseiPetrovski

Also you can set Git location in Jenkins server/node configuration:

您也可以在 Jenkins 服务器/节点配置中设置 Git 位置:

goto Configure, under section Node Properties mark checkbox Tools Location and set yours path to Git.

转到配置,在节点属性部分下标记复选框工具位置并将您的路径设置为 Git。

enter image description here

在此处输入图片说明

回答by Andrew

It seems Jenkins has been changing a lot. I fixed this problem in March 2017 by doing this:

詹金斯似乎发生了很大的变化。我在 2017 年 3 月通过这样做解决了这个问题:

  1. Go to Manage Jenkins
  2. Go to Global Tool Configuration
  3. In Git / Path to Git executableenter C:\<whatever the path is>\git.exe.
  4. Click on Save.
  1. 转到管理詹金斯
  2. 转到全局工具配置
  3. Git / Path to Git executable输入C:\<whatever the path is>\git.exe.
  4. 单击保存。

回答by colbadhombre

I had the correct path to git in Jenkins, but I had not yet accepted the Xcode build tools EULA on a fresh install of OS X Yosemite, so git looked like it was failing in Jenkins. After trying "git --version" on the git at /usr/bin/git in a terminal, I was given a command-line interface to accept the EULA, and then Jenkins could then access the git URL I had given the build project.

我在 Jenkins 中有正确的 git 路径,但我还没有在全新安装的 OS X Yosemite 上接受 Xcode 构建工具 EULA,所以 git 看起来在 Jenkins 中失败了。在终端中的 /usr/bin/git 上的 git 上尝试“git --version”后,我得到了一个命令行界面来接受 EULA,然后 Jenkins 可以访问我为构建项目提供的 git URL .

回答by Hailin Tan

Like Darksaint2014 said, you need to configure two parts if you installed Jenkins in Windows.

就像Darksaint2014说的,Windows下安装Jenkins需要配置两部分。

If you installed your Jenkins in windows, you need to install Git in both local and your linux server, then configure below in both locations:

如果你在 windows 上安装了 Jenkins,你需要在本地和你的 linux 服务器上安装 Git,然后在两个位置进行如下配置:



Global tool configuration:

全局工具配置:

global tool configuration

全局工具配置



For server side:

对于服务器端:

For server side

对于服务器端



回答by Sharoukh Akbar

Please install git in your Jenkins server. For example, if you are using Red Hat Enterprise Linux where you are hosting Jenkins, then install git in that server using the following command: sudo yum install gitThis should solve the problem as git executable will be available in /usr/bin/gitthen and this will be recognized automatically by jenkins and this you can verify by navigating to Manage Jenkins --> Global Tool Configuration. Then under Git installations, there will not be any warning and now you should be able to clone your git project in jenkins. Hope this help the users.

请在您的 Jenkins 服务器中安装 git。例如,如果您在托管 Jenkins 的地方使用 Red Hat Enterprise Linux,则使用以下命令在该服务器中安装 gitsudo yum install git这应该可以解决问题,因为 git 可执行文件将在/usr/bin/git 中可用然后,这将被 jenkins 自动识别,您可以通过导航到Manage Jenkins --> Global Tool Configuration来验证这一点。然后在Git installations 下,不会有任何警告,现在您应该能够在 jenkins 中克隆您的 git 项目。希望这对用户有所帮助。

回答by amazia

I had similar problem, the solution for Windows looks the same (my Jenkins is installed on a Windows machine):

我有类似的问题,Windows 的解决方案看起来相同(我的 Jenkins 安装在 Windows 机器上):

Global settings:

全局设置:

Go to Manage jenkins -> Configure System -> Git installationsadd there the git exe path (for example: C:\Program Files\Git\bin\git.exe), or you can use environment variable.

转到管理 jenkins -> 配置系统 -> Git 安装在那里添加 git exe 路径(例如:)C:\Program Files\Git\bin\git.exe,或者您可以使用环境变量。

For Jenkins version 2.121.3, Go to Manage jenkins -> Global tool configuration -> Git installations -> Path to Git executable: C:\Program Files\Git\bin\git.exe

对于 Jenkins 版本 2.121.3,转到管理 jenkins -> 全局工具配置 -> Git 安装 -> Git 可执行文件的路径C:\Program Files\Git\bin\git.exe

Jenkins job side:

詹金斯工作方面:

Go to Source code Management -> select git, add your repository, choose connection to repository (http/ssh) and add credentials and it should work.

转到Source code Management -> 选择 git,添加您的存储库,选择连接到存储库(http/ssh)并添加凭据,它应该可以工作。

回答by mwopata

I had a similar problem finding the git executable on OS X.

我在 OS X 上找到 git 可执行文件时遇到了类似的问题。

I had to change my Path to Git executableto : /usr/local/git/bin/git

我不得不将我的Git 可执行文件路径更改为:/usr/local/git/bin/git

Might give that a shot if you are still stuck.

如果你仍然被卡住,可能会试一试。

回答by mehmet6parmak

Another issue i faced with was, ssh.exe was not looking at the %userprofile%/.sshfolder for the key files. Instead it was looking to the folder C:\Program Files (x86)\Git\.sshwhich was empty and which causes a hang due to ssh authentication prompt on the machine where git repo located.

我面临的另一个问题是,ssh.exe 没有查看%userprofile%/.ssh密钥文件的文件夹。相反,它正在查找C:\Program Files (x86)\Git\.ssh空的文件夹,该文件夹由于 git repo 所在机器上的 ssh 身份验证提示而导致挂起。

We just copied the key files under %userprofile%/.sshto C:\Program Files (x86)\Git\.sshand the problem is resolved.

我们只是将关键文件复制到 下%userprofile%/.sshC:\Program Files (x86)\Git\.ssh问题就解决了。

回答by mehmet6parmak

If you do not copy and paste the full file path addess e.g. C:\Program Files\Git\bin\git.exe, in the 'path to executable' field when configuring Git, it can lead to errors. Windows 8 & 10 for instance have a 'copy path' functionality which really works and helps to get full path name. Mac should have something similar. Its always best to use that rather clicking in the path address address bar and copying. This does not usually give the full file path and may cause a lot of troubles if you forget to edit the path at its destination.

如果您C:\Program Files\Git\bin\git.exe在配置 Git 时没有复制并粘贴完整的文件路径地址,例如,在“可执行文件的路径”字段中,则可能会导致错误。例如,Windows 8 和 10 具有“复制路径”功能,该功能确实有效并有助于获取完整路径名。Mac应该有类似的东西。最好使用它而不是单击路径地址地址栏并复制。这通常不会给出完整的文件路径,如果您忘记编辑目的地的路径,可能会导致很多麻烦。

Path copycopyis also very good add-on for copying full path

Path copycopy也是一个很好的复制完整路径的插件

enter image description here

在此处输入图片说明