I want to install a gitlab-runner
(executor shaell
) on my Windows 10 box. I start the job on the gitlab server and it always ends up with the message the command "git" cannot be found
(roughly translated into english).
As a matter of fact git
is not part of my path.
How can I modify my PATH
variable for the shell the gitlab-runner
starts?
To use git on the command line in windows I usually set it with the statement: PATH %PATH%C:\Program Files\Git\bin
.
Is it documented somewhere, git
has to be available to the runner?
How can I see the command line the runner invokes (i.e. the call to git)?
Gitlab Runner is an application that works with GitLab CI/CD to run the job in a pipeline. It is open-source and written in Go Language. It can also be run inside the Docker container or it can be deployed into a Kubernetes cluster.
Summary. GitLab runner's pwsh shell runs as the root user on linux systems, not gitlab-runner user like the rest of the shell executors.
In GitLab, CI/CD variables can be defined by going to Settings » CI/CD » Variables, or by simply defining them in the . gitlab-ci. yml file. Variables are useful for configuring third-party services for different environments, such as testing , staging , production , etc.
For testing purposes I started the gitlab-runner
like: gitlab-runner -l debug --debug run --config config.toml --service gitlab-runner
from the directory where the gitlab-runner.exe
and the config.toml
file reside.
I added the following line to the runners
section of my config.toml
file:
environment = ['PATH=%PATH%;d:/java/bin;C:/Program Files/Git/bin;c:/program files (x86)/apache-ant-1.10.1/bin']
This GitLab Runner issue answers your question.
The environment
setting doesn't work since it gets evaluated before the variables are set, but you can use pre_build_script
in the runner config to update the path.
[[runners]]
name = "My Runner"
url = "https://gitlab.com/"
token = "Abcd1234"
executor = "shell"
pre_build_script = "set Path=%GIT_HOME%\\usr\\bin;%Path%"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With