2

I was just trying to work with GitLab CI/CD. I created a test angular project which had only one component, and worked fine. Then I started the GitLab Runner in that project. Added a .yml file to run the project. But the pipeline failed all the time. Then for testing purpose, I removed all the scripts for running the project, and just added some echo statements. Even then my pipeline failed. It is showing that

& : The term 'git' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Screenshot of yml script

enter image description here

Error message showed in GitLab

enter image description here

Divya_Bini
  • 31
  • 5
  • This means that the "git" command cannot be found. Is Git installed on your build runner host and available in PATH? – knittl Mar 10 '20 at 06:42
  • I have added the PATH. And Git is installed globally. – Divya_Bini Mar 10 '20 at 06:45
  • Show the contents of your gitlab runner toml configuration file, I don't where is the path on Windows machine, But it should be something like `config.toml` in "C:\GitLab-Runner\". – Gasol Mar 10 '20 at 10:06

3 Answers3

0

This is because git is not available in your runner path.

  1. Make sure Git is installed in your runner
before_script:
  - apt-get install git-core
  1. If installed try restarting the runner instance

Issue Links-

  1. https://gitlab.com/gitlab-org/gitlab-runner/issues/2743

  2. Git is not recognized in Windows gitlab ci

Ismail
  • 1,188
  • 13
  • 31
  • Please could you tell me how do I install Git in my runner? I have tried many ways, so I think I might have done it. But I am not sure about which step are you refering to. – Divya_Bini Mar 10 '20 at 06:57
  • `apt-get` will not work in a powershell script/runner. – knittl Mar 11 '20 at 06:19
0

I uninstalled my git and reinstalled it. The location I provided for environment path was different, than the one in which the git was actually installed at. Hence, when I reinstalled it, it got automatically installed into my C drive(this was the environment path I had set, I got this path while I was searching for solutions in net). I had not cross checked, whether actually my git location was C or not. I thought it might have been saved in C itself, but it was actually saved in some other location.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Divya_Bini
  • 31
  • 5
0

After installing the git from git-scm.com you must restart the gitlab-runner service.

I had problem in windows server and eventually become fixed :)

# gitlab-runner stop
# gitlab-runner start
Ghominejad
  • 1,572
  • 16
  • 15