繁体   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"

我正在尝试在本地运行我的 GitLab CI 测试,以加快 CI 的开发速度。

我按照这些说明在本地(在我的 GNU/Linux 机器上)安装了gitlab-runner

现在,当我运行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是包含.gitlab-ci.yml和我的项目代码的工作目录的实际路径)

因此,看起来gitlab-runner试图将目录路径用作 git clone URL,这显然行不通。

我尝试指定--clone-url= ,但我不明白我应该使用完整项目 URL 的哪一部分(在主 git repo 或 gitlab 镜像中)。

有什么线索吗?

如果您使用 Fedora 并且启用了 SELinux; 尝试将其设置为宽松:

sudo setenforce 0

SELinux 会阻止某些现有策略不允许的任何活动。 GitLab 运行器基本上是一个 docker 容器,试图访问主机上的文件,因此被阻止......这导致运行器报告您没有有效的存储库(错误说它无法读取文件会更有意义,但我们并不生活在一个完美的世界中)

懒惰的解决方法是让 SELinux 全面允许该活动,例如,如果您不经常执行此类操作以保证策略更改。

更有安全意识的人更愿意编辑策略。 在拒绝错误中找出一些唯一标识符,然后创建一个新策略以允许它

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