gitlab-runner 的权限被拒绝

问题描述 投票:0回答:1

我一直在尝试使用新创建的 Gitlab 运行程序作为 shell 执行器在 Gitlab 中运行 CI 作业,但是我的作业立即失败并显示以下输出:

$ apt-get --quiet update --yes
Reading package lists...
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)

我已检查作业在 gitlab-runnner 用户下运行,并且我尝试按以下方式编辑 sudoers 文件

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL
gitlab-runner ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d
gitlab-runner ALL=(ALL) NOPASSWD: ALL

但是,当我尝试在没有 ci 作业的情况下尝试在 gitlab runner 上检查命令的执行情况时,没有任何帮助:

sudo -u gitlab-runner apt-get --quiet update --yes
Reading package lists...
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
gitlab-ci gitlab-ci-runner
1个回答
0
投票

之前_脚本:

  • apt update -y # 此行修复了它 - 感谢 sytech
  • apt-get install -qq git
  • “哪个 ssh-agent || ( apt-get install -qq openssh-client )”
  • 评估 $(ssh-agent -s)
  • ssh-添加 <(cat "$SSH_PRIVATE_KEY")
  • mkdir -p ~/.ssh
  • '[[ -f /.dockerenv ]] && echo -e "主机 * StrictHostKeyChecking 否 “ > ~/.ssh/config'
© www.soinside.com 2019 - 2024. All rights reserved.