gpt4 book ai didi

windows - Jenkins Windows Slave 忽略本地 Git 设置

转载 作者:可可西里 更新时间:2023-11-01 14:13:34 25 4
gpt4 key购买 nike

我已经为 Unix Jenkins 主机设置了一个 Windows Jenkins 从机。我正在运行带有 msysgit 1.9.5 和 Jenkins 1.616 的 Windows 8.1。

当 check out 路径/文件名超过 255 个字符的存储库时,我收到“文件名太长”错误。这是 solved通过在 git 设置中将 core.longpaths 设置为 true。然而,Windows Jenkins 从属忽略自定义设置并使用标准设置。

我尝试过的

  • 在全局、系统、本地设置的 Windows Jenkins 从站上设置 core.longpaths:

    git config --global core.longpaths true
    git config --system core.longpaths true
    git config --local core.longpaths true
  • 在 Unix Jenkins Master 上设置 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 从服务器上克隆具有很长路径/文件名的存储库。

enter image description here

什么不起作用

在 Windows Jenkins 从服务器上用很长的路径/文件名克隆同一个存储库 Jenkins

    Started by user mles
[EnvInject] - Loading node environment variables.
Building remotely on jw10 in workspace D:\workspace\windowstesting
Cloning the remote Git repository
Cloning repository https://github.com/axelhodler/longfile.git
> git init D:\workspace\windowstesting # timeout=10
Fetching upstream changes from https://github.com/axelhodler/longfile.git
> git --version # timeout=10
> git -c core.askpass=true fetch --tags --progress https://github.com/axelhodler/longfile.git +refs/heads/*:refs/remotes/origin/*
> git config remote.origin.url https://github.com/axelhodler/longfile.git # timeout=10
> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> git config remote.origin.url https://github.com/axelhodler/longfile.git # timeout=10
Fetching upstream changes from https://github.com/axelhodler/longfile.git
> git -c core.askpass=true fetch --tags --progress https://github.com/axelhodler/longfile.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
> git rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision 31b408748324aa6f361828e45ae1d374c3f0fc25 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 31b408748324aa6f361828e45ae1d374c3f0fc25
FATAL: Could not checkout null with start point 31b408748324aa6f361828e45ae1d374c3f0fc25
hudson.plugins.git.GitException: Could not checkout null with start point 31b408748324aa6f361828e45ae1d374c3f0fc25
...
Caused by: hudson.plugins.git.GitException: Command "git checkout -f 31b408748324aa6f361828e45ae1d374c3f0fc25" returned status code 128:
stdout:
stderr: fatal: cannot create directory at 'launchpad/projects/configurationAdminManager/gofer-configurationAdminManager-notification/src/com/mwaysolutions/gofer2/configurationAdminManager/notification/dummydummy/dummydummy/dummydummy/dummydummy/dummydummy/dummydummy': Filename too long
....
Finished: FAILURE

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

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

最佳答案

无需更改运行 Jenkins 从站的用户,您可以直接对其进行配置。

  • 在适当的“管理” View 下设置一个名为 JenkinsSlaveScripts 的 Jenkins 多配置项目
  • 我使用基于矩阵的安全性来确保我的普通 Jenkins 用户不会运行它
  • 配置轴在所有 Windows 从机上运行
  • 添加“执行 Windows 批处理脚本”任务

添加脚本(类似)

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

当它运行时,它应该更新从站的配置,无论他们以谁的身份运行

关于windows - Jenkins Windows Slave 忽略本地 Git 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31812969/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com