Skip to content

Using GIT_CLONE_PATH doesn't work on Windows + PowerShell

I have a pretty standard GitLab Runner on Windows 10.

config.toml

[[runners]]
  name = "Eng Windows Build 2"
  url = "https://gitlab.com/"
  token = "..."
  builds_dir = "" # C:\gitlab-runner\builds
  executor = "shell"
  shell = "powershell"

I was having issues with Windows long file paths. I didn't want to mess with CI_BUILDS_DIR (it was relatively short already). The CI_PROJECT_DIR was relatively much longer. So, I tried changing it via GIT_CLONE_PATH.

.gitlab-ci.yml

variables:
  GIT_CLONE_PATH = $CI_BUILDS_DIR\eng

You can see in the pipeline log, that the GIT_CLONE_PATH is nicely normalized/escaped, but CI_BUILDS_DIR is not normalized/escaped.

Running with gitlab-runner 11.11.0~beta.1337.g83323c12 (83323c12)
  on Eng Windows Build 2 xxxxxxxx
ERROR: Job failed: the GIT_CLONE_PATH="C:\\gitlab-runner\\builds\\eng" has to be within "C:\\gitlab-runner/builds"

I'm pretty sure the problem is around here (the rootDir var is being passed in from StartBuild and god knows where that's coming from, so maybe it needs normalizing upstream somewhere): f4645bfb

Edited by Ghost User