Commit 45ed89c6 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'bugfix/windows-long-paths' into 'master'

Add support for Long Paths on Windows (Fixes #125)

This MR adds support for removing directories containing long paths (>260 characters) when using the PowerShell shell implementation. This support is implemented through detection of [NTFSSecurity](https://ntfssecurity.codeplex.com/)'s `Remove-Item2` command which has support for long paths, falling back on `Remove-Item` when it cannot be found.

In addition to this functionality, a workaround involving `git fetch` and `git config --system core.longpaths true` has been documented in the FAQ.

For a full discussion of possible solutions and the original problem, please look at #125

See merge request !19
parents a39f759d 19a92ac9
v 0.6.0 (unreleased)
- Fetch docker auth from ~/.docker/config.json or ~/.dockercfg
- Added support for NTFSSecurity PowerShell module to address problems with long paths on Windows
v 0.5.2
- Fixed CentOS6 service script
......
......@@ -12,3 +12,21 @@ Is it possible to run GitLab Runner in debug/verbose mode. Do it from terminal:
```
gitlab-runner --debug run
```
## 3. I get a PathTooLongException during my builds on Windows
This is caused by tools like `npm` which will sometimes generate directory structures
with paths more than 260 characters in length. There are two possible fixes you can
adopt to solve the problem.
### a) Use Git with core.longpaths enabled
You can avoid the problem by using Git to clean your directory structure, first run
`git config --system core.longpaths true` from the command line and then set your
project to use *git fetch* from the GitLab CI project settings page.
### b) Use NTFSSecurity tools for PowerShell
The [NTFSSecurity](https://ntfssecurity.codeplex.com/) PowerShell module provides
a *Remove-Item2* method which supports long paths. The Gitlab CI Multi Runner will
detect it if it is available and automatically make use of it.
\ No newline at end of file
......@@ -29,7 +29,13 @@ func (b *PowerShell) writeCommandChecked(w io.Writer, format string, args ...int
func (b *PowerShell) writeCloneCmd(w io.Writer, build *common.Build, dir string) {
b.writeCommand(w, "echo \"Cloning repository...\"")
b.writeCommandChecked(w, "if(Test-Path \"%s\") { Remove-Item -Force -Recurse \"%s\" }", dir, dir)
b.writeCommand(w, "$NTFSSecurityRemoveItem2 = Get-Command Remove-Item2 -ErrorAction SilentlyContinue")
b.writeCommand(w, "$HasNTFSSecurityRemoveItem2 = ($NTFSSecurityRemoveItem2 -ne $null) -and ($NTFSSecurityRemoveItem2.ModuleName -eq \"NTFSSecurity\")")
b.writeCommand(w, "if($HasNTFSSecurityRemoveItem2 -and Test-Path \"%s\") {", dir)
b.writeCommandChecked(w, "Remove-Item2 -Force -Recurse \"%s\"", dir)
b.writeCommand(w, "} elseif(Test-Path \"%s\") {")
b.writeCommandChecked(w, "Remove-Item -Force -Recurse \"%s\"", dir)
b.writeCommand(w, "}")
b.writeCommandChecked(w, "(Test-Path \"%s\") -or (New-Item \"%s\" -ItemType \"directory\" )", dir, dir)
b.writeCommandChecked(w, "git clone \"%s\" \"%s\"", build.RepoURL, dir)
b.writeCommandChecked(w, "cd \"%s\"", dir)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment