【问题标题】:Windows Git issue with Network Path网络路径的 Windows Git 问题
【发布时间】:2016-06-30 08:09:25
【问题描述】:

我有一个带有裸存储库的网络文件夹。

我正在使用 Jenkins 尝试创建一个构建任务,该任务检查一个项目并使用 Git 插件和 MsBuild 插件构建它。

Jenkins windows 服务作为服务帐户运行,我们称之为 svcBuilder

服务帐户有权访问网络文件夹。我通过以 svcBuilder 身份登录构建服务器、打开 Windows 资源管理器并粘贴 URI(例如 \\machine\folder\repo)来验证这一点,我可以正常访问存储库。

在 Jenkins 中,我将此路径更改为 //machine/folder/repo(根据许多帖子建议)。

现在,当我将存储库本地复制到构建服务器时,没有错误(因此我确定存储库正常运行)。但是,当我尝试通过网络访问同一个存储库时,出现错误:

Failed to connect to repository : Command "C:\Program Files\Git\bin\git.exe -c core.askpass=true ls-remote -h //machine/folder/repo HEAD" 
returned status code 128:
stdout: 
stderr: fatal: unable to get current working directory: No such file or directory
fatal: The remote end hung up upon initial contact

谁能指出我正确的方向,因为 git 正在做什么导致这种情况?我无法更改 git 命令,因为它是由 Jenkins 插件生成的。

【问题讨论】:

  • 好的,奇怪的发展:当我将网络驱动器映射到有问题的文件夹时,git 工作正常。使用 \\machine\folder\repo,无论斜线采用哪种方式似乎都不起作用。
  • 更奇怪的是,驱动器的映射似乎只有在 Windows 命令行中使用 git 时才有效。当我从 Bash 使用 git 时,我收到一条错误消息,指出存储库不是 git 存储库。

标签: windows git jenkins


【解决方案1】:

好的,为了让它工作,我下载并解压了Sysinternals Suite 到我的 C:\Program Files (x86)\SysinternalsSuite。然后我为 Jenkins 安装了 pre-scm-buildstep 插件。然后我添加了以下 pre-scm-buildStep 'windows batch command'。

IF EXIST Y:\NUL GOTO REPOEXISTS
"C:\Program Files (x86)\SysinternalsSuite\psexec" -s net use Y: \\Machine\folder\repository jenkinsServiceUserPassword /u:DOMAIN\jenkinsServiceUser /persistent:yes
:REPOEXISTS

这样,如果服务器重新启动,我就不必乱用登录脚本或依赖预先正确设置的驱动器,脚本只需测试驱动器是否存在并在它丢失时映射它。顺便说一句,jenkinsServiceUser 在构建服务器上是管理员。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 2018-01-26
    • 2014-09-27
    • 1970-01-01
    相关资源
    最近更新 更多