为什么通过 hudson 执行 git fetch 失败,而通过命令行执行 git fetch 有效?

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

Why does git fetch via hudson fail, while git fetch via the command line works?

githudsongit-fetch

提问by mmr

I'm trying to fetch a read-only git repository from github and have it be built via hudson. This process is failing.

我正在尝试从 github 获取只读 git 存储库并通过 hudson 构建它。这个过程失败了。

This is the hudson output:

这是哈德逊输出:

Started by an SCM change
Checkout:workspace / d:\hudson\home\jobs\gdcm-hudson\workspace - hudson.remoting.LocalChannel@19ba1d8
Using strategy: Default
Checkout:workspace / d:\hudson\home\jobs\gdcm-hudson\workspace - hudson.remoting.LocalChannel@19ba1d8
GitAPI created
Fetching changes from the remote Git repository
Fetching upstream changes from git://github.com/malaterre/gdcm.git
[workspace] $ "C:\Program Files (x86)\Git\bin\git.exe" fetch -t git://github.com/malaterre/gdcm.git +refs/heads/*:refs/remotes/origin/*
[workspace] $ "C:\Program Files (x86)\Git\bin\git.exe" ls-tree HEAD
ERROR: Problem fetching from origin / origin - could be unavailable. Continuing anyway
ERROR: Could not fetch from any repository
FATAL: Could not fetch from any repository
hudson.plugins.git.GitException: Could not fetch from any repository
    at hudson.plugins.git.GitSCM.invoke(GitSCM.java:674)
    at hudson.plugins.git.GitSCM.invoke(GitSCM.java:641)
    at hudson.FilePath.act(FilePath.java:753)
    at hudson.FilePath.act(FilePath.java:735)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:641)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1061)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:479)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:411)
    at hudson.model.Run.run(Run.java:1273)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:129)

When I run that fetch command directly via the git bash command line, I get no response (which I assume means it's worked).

当我通过 git bash 命令行直接运行该 fetch 命令时,我没有得到任何响应(我认为这意味着它有效)。

I looked at this possible solution: http://issues.hudson-ci.org/browse/HUDSON-7141?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel

我查看了这个可能的解决方案:http: //issues.hudson-ci.org/browse/HUDSON-7141?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel

But using that version of the plugin did not change this behavior.

但是使用该版本的插件并没有改变这种行为。

I haven't even gotten to having it work with cmake yet, just downloaded consistently. How can I get this to work?

我什至还没有让它与 cmake 一起工作,只是一直下载。我怎样才能让它工作?

edit: This problem is not a repro of Problem cloning / fetching repository using Git plugin for Hudson on Windows, because I'm not running as a service on a server.

编辑:这个问题不是在 Windows 上使用 Hudson 的 Git 插件克隆/获取存储库问题的重现,因为我没有在服务器上作为服务运行。

采纳答案by kelloti

Yes, I just fixed this exact problem. If you open a windows explorer to d:\hudson\home\jobs\gdcm-hudson\workspaceyou should be able to see a .gitdirectory and nothing else. There should be a working copy but there isn't. To fix this you have to "prime" the repository by running

是的,我刚刚解决了这个确切的问题。如果您打开 Windows 资源管理器,d:\hudson\home\jobs\gdcm-hudson\workspace您应该能够看到一个.git目录,而没有其他内容。应该有一个工作副本,但没有。要解决此问题,您必须通过运行“准备”存储库

git pull git://github.com/malaterre/gdcm.git

This should create a bunch of other files in d:\hudson\home\jobs\gdcm-hudson\workspacealong side the .git directory and you should be able to perform a build in hudson.

这应该会d:\hudson\home\jobs\gdcm-hudson\workspace在 .git 目录旁边创建一堆其他文件,您应该能够在 hudson 中执行构建。

回答by goto10

This occurred to me on a build that was previously working fine. The solution was just to delete the workspace directory and restart the build.

这发生在我之前运行良好的构建中。解决方案只是删除工作区目录并重新启动构建。

回答by VonC

The Git plugin for Hudson fails only recently on this kind of error message (issue 6902, July 2010). Before it used to go on silently (which was misleading).

Hudson 的 Git 插件最近才在出现此类错误消息时失败(问题 6902,2010 年 7 月)。之前它曾经默默地继续(这是误导)。

Do you have any submodules defined?
Because it looks like Git Plugin Bug 4

您是否定义了任何子模块?
因为它看起来像Git Plugin Bug 4

I have the following setup:

  • a branch called "master", that contains a submodule to another project
  • a branch called "develop", that does not contain a submodule reference

If I configure a Hudson job to build/test the "develop" branch, the build breaks, because it cannot do the submodule checkout. Because this happens before switching to the "develop" branch, the build is broken before anything started.

Solution

I assume the output of git ls-tree HEADis scanned for 160000 references to determine which entries are submodules.
The ref HEADat that point still points to master, I suppose in most cases.
Instead of ls-tree'ing HEAD, maybe do it on the specified branch?

我有以下设置:

  • 一个名为“master”的分支,包含另一个项目的子模块
  • 一个名为“develop”的分支,不包含子模块引用

如果我配置一个 Hudson 作业来构建/测试“开发”分支,则构建会中断,因为它无法执行子模块检出。因为这是在切换到“开发”分支之前发生的,所以构建在任何开始之前就被破坏了。

解决方案

我假设git ls-tree HEAD扫描 160000 个引用的输出以确定哪些条目是子模块。我想在大多数情况下,那时
的 refHEAD仍然指向master
而不是ls-tree'ing HEAD,也许在指定的分支上做?

回答by acneto

After deleting the Hudson workspace directory .hudson, it works for me. I'm using Hudson 2.2.1and the git plugin 2.2.1.

删除 Hudson 工作区目录后.hudson,它对我有用。我正在使用Hudson 2.2.1git plugin 2.2.1.

回答by oliver

For the record, in my case the problem was that there was a special Git executable configured (in global Hudson settings). This executable failed to run on some of my build hosts due to missing libraries. When using /usr/bin/git instead it worked.

作为记录,就我而言,问题是配置了一个特殊的 Git 可执行文件(在全局 Hudson 设置中)。由于缺少库,此可执行文件无法在我的某些构建主机上运行。当使用 /usr/bin/git 时,它起作用了。

So it looks like the described error message really can indicate anyGit error at all.

所以看起来所描述的错误消息真的可以表明任何Git 错误。