Jenkins Windows Slave忽略本地Git设置

Jenkins Windows Slave忽略本地Git设置,windows,git,jenkins,Windows,Git,Jenkins,我已将Windows Jenkins从系统设置为Unix Jenkins主系统。我使用msysgit 1.9.5和Jenkins 1.616运行Windows 8.1 当签出路径/文件名长度超过255个字符的存储库时,我会出现“文件名过长”错误。这是通过在git设置中将core.longpaths设置为true实现的。但是,Windows Jenkins从属服务器忽略自定义设置,并使用标准设置 我尝试过的 在Windows Jenkins slave的全局、系统、本地设置中设置core.lon

我已将Windows Jenkins从系统设置为Unix Jenkins主系统。我使用msysgit 1.9.5和Jenkins 1.616运行Windows 8.1

当签出路径/文件名长度超过255个字符的存储库时,我会出现“文件名过长”错误。这是通过在git设置中将
core.longpaths
设置为true实现的。但是,Windows Jenkins从属服务器忽略自定义设置,并使用标准设置

我尝试过的

  • 在Windows Jenkins slave的全局、系统、本地设置中设置
    core.longpaths

    git config --global core.longpaths true
    git config --system core.longpaths true
    git config --local core.longpaths true
    
  • 在Unix Jenkins主机上设置
    core.longpaths

结果

Windows Jenkins slave仍在使用默认设置运行git。我已经完成了一个简单的构建任务

"C:\Program Files (x86)\Git\bin\git.exe" config -l
产生

Started by user mles
[EnvInject] - Loading node environment variables.
Building remotely on jw10 in workspace D:\workspace\windowstesting
[windowstesting] $ sh -xe C:\WINDOWS\TEMP\hudson2817786906482449008.sh
+ 'C:\Program Files (x86)\Git\bin\git.exe' config -l
core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true
Finished: SUCCESS
注意:否
core.longpaths=true
。在Windows上,设置了Jenkins slave
core.longpaths=true

C:\Users\jw>git config -l
core.symlinks=false
core.autocrlf=true
core.longpaths=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true
什么有效

在没有Jenkins的Windows Jenkins slave上本地克隆具有很长路径/文件名的存储库

什么不起作用

使用Jenkins在Windows Jenkins slave上克隆具有很长路径/文件名的同一存储库

我不能在开始时添加另一个构建步骤来设置
core.longpaths
,因为在运行任何构建步骤之前,检查存储库是jenkins做的第一件事


你知道为什么我的Windows Jenkins slave会忽略自定义设置吗?

Jenkins slave应该以用户身份运行
jw
。这将使git获取您为此用户输入的所有设置。
如果作为服务运行,请将服务更新为以用户
jw
而不是系统用户的身份运行


我希望这会有所帮助。

您可以直接配置Jenkins slave,而不是更改其运行的用户

  • 在适当的“管理”视图下设置一个名为JenkinsSlavescript的Jenkins多配置项目
  • 我使用基于矩阵的安全性来确保我的普通Jenkins用户不会运行它
  • 将axis配置为在所有Windows从属设备上运行
  • 添加“执行Windows批处理脚本”任务
将脚本添加为(类似于)


当它运行时,无论从机运行的是谁,它都应该更新从机的配置,就像在我的案例中运行的解决方案一样:

  • 转到git安装文件夹

  • 然后编辑Git\etc\gitconfig

  • 确保它包含

    [核心] 长路径=真

  • 例如:

    [http]
        sslBackend = schannel
    [diff "astextplain"]
        textconv = astextplain
    [filter "lfs"]
        clean = git-lfs clean -- %f
        smudge = git-lfs smudge -- %f
        process = git-lfs filter-process
        required = true
    [core]
        autocrlf = false
        fscache = true
        symlinks = false
        longpaths = true
    [pull]
        rebase = true 
    

    我怀疑Jenkins slave没有以用户“jw”的身份运行。如果它是一个服务,它可能以系统用户的身份运行。您可以将服务更改为作为专用用户“jw”运行。您猜对了。将此作为常规答案添加,我将接受它。
    cd c:\dev-software\git-2.7.1\bin
    git config --global core.longpaths true
    git config --system core.longpaths true
    git config --local core.longpaths true
    echo %USERPROFILE%\.gitconfig on %COMPUTERNAME%
    type %USERPROFILE%\.gitconfig
    
    [http]
        sslBackend = schannel
    [diff "astextplain"]
        textconv = astextplain
    [filter "lfs"]
        clean = git-lfs clean -- %f
        smudge = git-lfs smudge -- %f
        process = git-lfs filter-process
        required = true
    [core]
        autocrlf = false
        fscache = true
        symlinks = false
        longpaths = true
    [pull]
        rebase = true