GitLab 执行器错误 "You lack permissions to write to system configuration."

GitLab Executor Error "You lack permissions to write to system configuration."

我有一个带有 Linux 的 AWS EC2。我已经在上面安装了 GitLab runner,我已经按照 https://docs.gitlab.com/runner/install/linux-repository.html for RHEL/CentOS/Fedora。它是一个 Shell 执行器。我已经注册了。然后在 EC2 上安装 Docker。

不过,当我启动管道时,出现此错误:

Initialized empty Git repository in /home/gitlab-runner/builds/xxxx/0/xxxx/xxxx/.git/
Created fresh repository.
Checking out b25b6b1a as develop...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:00
$ amazon-linux-extras install docker
You lack permissions to write to system configuration.  /etc/yum.repos.d/amzn2-extras.repo

有什么提示吗?

由于您使用的是“shell”执行器,因此您在管道中 运行 执行的命令实际上就像您通过 gitlab-runner 用户(假设您没有更改 运行 用户默认使用的用户)。默认情况下,该用户没有安装软件包的权限,这就是您在此处看到的错误。

您需要将 gitlab-运行ner 用户添加到 sudoers 文件,然后使用 sudo 到 运行 您的命令。

综上所述,是否有令人信服的理由让您不使用 docker 执行器?作业之间的隔离要干净得多。例如,如果您在一个 shell 执行器上同时有多个作业 运行ning 并且它们都安装包,那么这两个作业之一将由于无法获得包锁而失败。您可以使用 resource_group 解决此问题,但 docker 是更优雅的解决方案。