简体   繁体   English

gitlab-runner 使用目录路径而不是 URL 来克隆; 失败并显示“似乎不是 git 存储库”

[英]gitlab-runner using directory path instead of URL to clone; fails with "does not appear to be a git repository"

I am trying to run my GitLab CI tests locally, to speed up developing CI.我正在尝试在本地运行我的 GitLab CI 测试,以加快 CI 的开发速度。

I installed gitlab-runner locally (on my GNU/Linux box) following these instructions .我按照这些说明在本地(在我的 GNU/Linux 机器上)安装了gitlab-runner

Now, when I run sudo gitlab-runner exec docker test , I get:现在,当我运行sudo gitlab-runner exec docker test ,我得到:

sudo gitlab-runner exec docker test
Runtime platform                                    arch=amd64 os=linux pid=7133 revision=0e5417a3 version=12.0.1
Running with gitlab-runner 12.0.1 (0e5417a3)
Using Docker executor with image joyzoursky/python-chromedriver:2.7 ...
Pulling docker image joyzoursky/python-chromedriver:2.7 ...
Using docker image sha256:f593ebe67d0c75eb8e3d663412c8fc80df70bd08e835d7a64ba6afa21b1c2d8a for joyzoursky/python-chromedriver:2.7 ...
Running on runner--project-0-concurrent-0 via hostname...
Fetching changes...
Initialized empty Git repository in /builds/project-0/.git/
Created fresh repository.
fatal: '/home/USER/path/to/repo' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
ERROR: Job failed: exit code 1
FATAL: exit code 1                                 

( /home/USER/path/to/repo is the actual path to my working directory containing .gitlab-ci.yml , and my project code) /home/USER/path/to/repo是包含.gitlab-ci.yml和我的项目代码的工作目录的实际路径)

So, it looks like gitlab-runner is trying to use the directory path as a git clone URL, which obviously won't work.因此,看起来gitlab-runner试图将目录路径用作 git clone URL,这显然行不通。

I tried specifying --clone-url= , but I can't understand what part of the full project URL (either in the main git repo, or the gitlab mirror) I should be using.我尝试指定--clone-url= ,但我不明白我应该使用完整项目 URL 的哪一部分(在主 git repo 或 gitlab 镜像中)。

Any clues?有什么线索吗?

If you are on Fedora and have SELinux enabled;如果您使用 Fedora 并且启用了 SELinux; try setting that to permissive:尝试将其设置为宽松:

sudo setenforce 0

SELinux blocks any activity that isn't allowed by some existing policy. SELinux 会阻止某些现有策略不允许的任何活动。 The GitLab runner is basically a docker container trying to access files on the host machine, so that gets blocked...which leads the runner to report that you don't have a valid repository at (an error saying it can't read the files would have made more sense but we don't live in a perfect world) GitLab 运行器基本上是一个 docker 容器,试图访问主机上的文件,因此被阻止......这导致运行器报告您没有有效的存储库(错误说它无法读取文件会更有意义,但我们并不生活在一个完美的世界中)

The lazy fix is to make SELinux blanket permit the activity, if you don't do this sort of thing often enough to warrant a policy change for example.懒惰的解决方法是让 SELinux 全面允许该活动,例如,如果您不经常执行此类操作以保证策略更改。

The more security conscious will prefer to edit the policy instead.更有安全意识的人更愿意编辑策略。 Figure out some unique identifier in the denial error, then create a new policy to allow it在拒绝错误中找出一些唯一标识符,然后创建一个新策略以允许它

sudo grep <needle> /var/log/audit/audit.log | audit2allow -M gitlab
sudo semodule -i gitlab.pp

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM