首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gitlab-runner无法删除拒绝的权限

Gitlab-runner无法删除拒绝的权限
EN

Stack Overflow用户
提问于 2020-02-24 22:02:11
回答 4查看 6.7K关注 0票数 4

我正在和Gitlab建立CI/CD管道。我已经在Digital Ocean Ubuntu18.04上安装了gitlab-runner,并在/etc/sudoers中将权限授予gitlab-runner:

代码语言:javascript
复制
gitlab-runner ALL=(ALL:ALL)ALL

对关联存储库的第一次提交正确地构建了docker-compose (应用程序本身是Django+postgres),但以下提交无法清理先前的构建并失败:

代码语言:javascript
复制
Running with gitlab-runner 12.8.0 (1b659122)
on ubuntu-s-4vcpu-8gb-fra1-01 52WypZsE
Using Shell executor...
00:00
Running on ubuntu-s-4vcpu-8gb-fra1-01...
00:00
Fetching changes with git depth set to 50...
00:01
 Reinitialized existing Git repository in /home/gitlab-runner/builds/52WypZsE/0/lorePieri/djangocicd/.git/
 From https://gitlab.com/lorePieri/djangocicd
  * [new ref]         refs/pipelines/120533457 -> refs/pipelines/120533457
    0072002..bd28ba4  develop                  -> origin/develop
 Checking out bd28ba46 as develop...
 warning: failed to remove app/staticfiles/admin/img/selector-icons.svg: Permission denied
 warning: failed to remove app/staticfiles/admin/img/search.svg: Permission denied
 warning: failed to remove app/staticfiles/admin/img/icon-alert.svg: Permission denied
 warning: failed to remove app/staticfiles/admin/img/tooltag-arrowright.svg: Permission denied
 warning: failed to remove app/staticfiles/admin/img/icon-unknown-alt.svg: Permission denied

这是.gitlab-ci.yml文件的相关部分:

代码语言:javascript
复制
image: docker:latest
services:
  - docker:dind

stages:
  - test
  - deploy_staging
  - deploy_production

step-test:
  stage: test
  before_script:
    - export DYNAMIC_ENV_VAR=DEVELOP
  only:
    - develop
  tags:
    - develop
  script:
    - echo running tests in $DYNAMIC_ENV_VAR
    - sudo apt-get install -y python-pip
    - sudo pip install docker-compose
    - sudo docker image prune -f
    - sudo docker-compose -f docker-compose.yml build --no-cache
    - sudo docker-compose -f docker-compose.yml up -d
    - echo do tests now
    - sudo docker-compose exec -T web python3 -m coverage run --source='.' manage.py test

...

我尝试过的:

代码语言:javascript
复制
usermod -aG docker gitlab-runner
sudo service docker restart
EN

回答 4

Stack Overflow用户

发布于 2021-05-26 17:22:25

对我来说最好的解决方案是添加

代码语言:javascript
复制
pre_clone_script = "sudo chown -R gitlab-runner:gitlab-runner ."

/etc/gitlab-runner/config.toml中,即使您在前一个作业之后没有权限,它也会在清理工作目录和克隆存储库之前设置正确的权限。

票数 4
EN

Stack Overflow用户

发布于 2020-03-06 17:00:19

我建议在受影响的工作中将GIT_STRATEGY设置为none。

票数 1
EN

Stack Overflow用户

发布于 2021-06-24 18:41:09

我也遇到过完全相同的问题。因此,我将详细解释它是如何解决的。

尝试查找您的config.toml文件并使用根权限运行gitlab-runner命令,因为权限被拒绝是一个非常常见的基于UNIX的操作系统错误。

找到config.toml的位置后,传递它:

代码语言:javascript
复制
sudo gitlab-runner run --config <absolute_location_of_config_toml>

P.S.你可以使用locate config.toml命令很容易地找到所有的config.toml文件。通过执行sudo apt-get install mlocate确保已安装

  1. 在遇到permission denied错误后,我尝试使用sudo gitlab-runner run而不是gitlab-runner,但它有自己的问题:

错误:无法加载config stat /etc/gitlab-runner/config.toml:没有这样的文件或目录builds=0

在没有超级用户权限的情况下执行gitlab-runner时,没有任何配置文件问题。

  1. 尝试实现@Grumbank和@vlad-Mazurkov提到的方法和解决方案。但它们不能正常工作。
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60377532

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档