10

I configured a gitlab runner as explained here: https://docs.gitlab.com/runner/install/windows.html

Unfortunately, when I push to my repository, my pipeline fails:

Running with gitlab-runner 10.5.0 (80b03db9)
  on windows runner 79cb4019
Using Shell executor...
Running on WINSTD-45-13...
'"git"' is not recognized as an internal or external command,
operable program or batch file.
'"git"' is not recognized as an internal or external command,
operable program or batch file.
Cloning repository...
'"git"' is not recognized as an internal or external command,
operable program or batch file.
The system cannot find the path specified.
Checking out b05fd8be as master...
'"git"' is not recognized as an internal or external command,
operable program or batch file.
ERROR: Job failed: exit status 9009

When I open the command line utility as administrator, git is available.

Any idea why git is not recognized whithin the pipeline script?

Martin Delille
  • 11,360
  • 15
  • 65
  • 132
  • Is your gitlab-runner running as the User or Administrator? Is Git on the path which the gitlab-runner can access? – Rekovni Mar 07 '18 at 17:33
  • @Rekovni gitlab-runner is running as Administrator since I started it from an Administrator elevated command prompt as explained in the doc. Git is in the path (when I type `git` in the command prompt, it display `git` available commands) – Martin Delille Mar 07 '18 at 18:12

6 Answers6

9

If you installed git after gitlab-runner you have to restart gitlab-runner service.

Yunus Eş
  • 159
  • 1
  • 3
6

I solved the problem myself: my .gitlab-ci.yml script was redefining the PATH environment variable.

Martin Delille
  • 11,360
  • 15
  • 65
  • 132
6

For me it happened that I installed git after I started PowerShell to run gitlab-runner. To fix this you need to restart PowerShell after git is installed and then restart gitlab-runner to get git on your PATH.

RamiR
  • 139
  • 2
  • 8
1

My runner was installed on an Amazon EC2 instance, and I installed git after I installed the runner. I found restarting the entire EC2 instance fixed it. Restarting the service was not enough.

Cobertos
  • 1,953
  • 24
  • 43
1

I had installed git as a user, so it was installed to that user's AppData folder. Even though I could run git --version fine from an elevated console, GitLab for some reason couldn't run it.

I reinstalled git as Administrator, and then stopped and restarted the GitLab Runner service and now it is working properly.

cvanbeek
  • 1,796
  • 21
  • 30
0

Installing Git on C:\Git instead of c:\Program Files... fixed this problem for me.

ovsvolvic
  • 3
  • 1