4

I've setup a Windows Jenkins slave to a Unix Jenkins master. I'm running Windows 8.1 with msysgit 1.9.5 and Jenkins 1.616.

When checking out a repository with path/filename longer than 255 characters, I get the "Filename too long" error. This is solved by setting core.longpaths to true in the git settings. However the Windows Jenkins slave is ignoring the custom settings and uses standard settings.

What I've tried

  • Setting core.longpaths on the Windows Jenkins slave in global, system, local settings:

    git config --global core.longpaths true
    git config --system core.longpaths true
    git config --local core.longpaths true
    
  • Setting core.longpaths on the Unix Jenkins Master

The result

The Windows Jenkins slave is still running git with default settings. I've made a simple build task with

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

which yields

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

note no core.longpaths=true. On the Windows Jenkins slave core.longpaths=true is set

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

What works

Cloning a repository with very long path/filenames locally on the Windows Jenkins slave without Jenkins.

enter image description here

What does not work

Cloning the same repository with very long path/filenames on the Windows Jenkins slave with 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

I can not add another build step at the beginning to set core.longpaths, as checking out the repository is the first thing jenkins does before running any build steps.

Any ideas why custom settings are ignored by my Windows Jenkins slave?

Community
  • 1
  • 1
mles
  • 4,534
  • 10
  • 54
  • 94
  • 1
    I suspect the Jenkins slave is not running as user "jw". If it's a service, it might be running as system user. You can change the service to run as dedicated user "jw". – Eldad Assis Aug 04 '15 at 15:18
  • You suspected right. Add this as a regular answer and I'll accept it. – mles Aug 04 '15 at 17:29

3 Answers3

3

Instead of changing the user that the Jenkins slave is running as, you can get it configured directly.

  • Set up a Jenkins Multi-configuration project called something like JenkinsSlaveScripts under an appropriate 'Admin' view
  • I use matrix based security to ensure my regular Jenkins users won't run it
  • Configure the axis to run on all your Windows slaves
  • Add an "Execute Windows batch script" task

Add the script to be (something like)

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

When it runs it should update the config of the slaves no matter who they are running as

Spangen
  • 4,420
  • 5
  • 37
  • 42
2

Jenkins slave should be running as user jw. This will make git pick up all the settings you put in for this user.
If running as a service, update the service to run as user jw and not as system user.

I hope this helps.

Eldad Assis
  • 10,464
  • 11
  • 52
  • 78
0

The solution which worked in my case:

  1. Go to git installation folder,

  2. then edit Git\etc\gitconfig

  3. Be sure it contains

    [core] longpaths = true

example:

[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 
miedza
  • 1
  • 1