简体   繁体   中英

Windows Git issue with Network Path

I have a network folder with a bare repository.

I am using Jenkins to try to create a build task that checks out a project and builds it using the Git plugin and the MsBuild plugin.

The Jenkins windows service is running as a service account, lets call it svcBuilder

The service account has access to the network folder. I verified this by logging into the build server as svcBuilder, opening windows explorer and pasting the URI (ex. \\\\machine\\folder\\repo) in and I can access the repository just fine.

In Jenkins I changed this path to //machine/folder/repo (as per numerous post suggestions).

Now when I copy the repo locally to the build server, there are no errors (so I am sure the repository is functional). However when I try to access the same repository over the network, I get an error:

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

Can anyone point me in the right direction as to what git is doing that causes this? I cannot change the git command since it is generated by the Jenkins plugin.

Ok, so to get this to work I downloaded and extracted Sysinternals Suite to my C:\\Program Files (x86)\\SysinternalsSuite. I then installed the pre-scm-buildstep plugin for Jenkins. I then added the following 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

This way, if the server is rebooted I don't have to mess around with logon scripts or rely on the drive being set up correctly in advance, the script simply tests if the drive is there and maps it if it's missing. BTW the jenkinsServiceUser is admin on the build server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM