Runner 'git' not recognized windows 11

Problem to solve

Error on pipeline execution:

& "git" 'config' '-f' 'C:\gitlab-runner\builds\<some>\0\<some> …
     |    ~~~~~
     | The term 'git' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
ERROR: Job failed: exit status 1

Steps to reproduce

I’ve installed on a blank win 11 pro (vm) the necessary build / .NET tools to be able to build / publsh my solution using the pipeline in gitlab.

  • install pwsh version 7.x
  • install git
  • install and configure gitlab runner 17.0.0


The runner’s config is:

executor = "shell"
shell = "pwsh"

OS: Windows 11 Professional

my .gitlab-ci.yml is like this:

  - build
  - publish

  CI_DEBUG_TRACE: "true"
  DOTNET_ROOT: "C:\\Program Files\\dotnet"

  stage: build
    - windows
    - echo "Restoring dependencies..."
    - dotnet restore
    - echo "Building the solution..."
    - dotnet build --configuration Release
    - main


  • [x ] Self-managed Version 17

Already tried

  • I already tried modifying the runner’s config with
environment = ["PATH=C:\\Git\\cmd;%PATH%"]

and restart the runner afterwards

  • Modify the pipeline with
  PATH: "$PATH:C:\\Program Files\\Git\\cmd"

But both ways didn’t help at all.

It seems like all known workarounds don’t work (anymore). Or maybe I’m trying to long and already got blind for some simple issue.

Do you know how to fix it or what I did wrong?
Thank you very much

Hmm. Could you please try changing double quotes " with singles ', and using only 1 backward slash \? My config looks like this and works fine (on 16.11 runner though):

environment = ['PATH=%PATH%;C:\Program Files\Git\cmd;C:\Users\Administrator\AppData\Local\Programs\Python\Python312;C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Scripts']

and remove the config from the pipeline to avoid any accidental rewrites.


Thank you @paula.kokic
This did the trick.

I really don’t understand why I have to provide all the paths as they’re already set up as global env variables, but I’m happy that it works now :slight_smile: