我正在和Gitlab建立CI/CD管道。我已经在Digital Ocean Ubuntu18.04上安装了gitlab-runner,并在/etc/sudoers中将权限授予gitlab-runner:
gitlab-runner ALL=(ALL:ALL)ALL对关联存储库的第一次提交正确地构建了docker-compose (应用程序本身是Django+postgres),但以下提交无法清理先前的构建并失败:
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文件的相关部分:
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
...我尝试过的:
usermod -aG docker gitlab-runner
sudo service docker restart发布于 2021-05-26 17:22:25
对我来说最好的解决方案是添加
pre_clone_script = "sudo chown -R gitlab-runner:gitlab-runner ."在/etc/gitlab-runner/config.toml中,即使您在前一个作业之后没有权限,它也会在清理工作目录和克隆存储库之前设置正确的权限。
发布于 2020-03-06 17:00:19
我建议在受影响的工作中将GIT_STRATEGY设置为none。
发布于 2021-06-24 18:41:09
我也遇到过完全相同的问题。因此,我将详细解释它是如何解决的。
尝试查找您的config.toml文件并使用根权限运行gitlab-runner命令,因为权限被拒绝是一个非常常见的基于UNIX的操作系统错误。
找到config.toml的位置后,传递它:
sudo gitlab-runner run --config <absolute_location_of_config_toml>P.S.你可以使用locate config.toml命令很容易地找到所有的config.toml文件。通过执行sudo apt-get install mlocate确保已安装
permission denied错误后,我尝试使用sudo gitlab-runner run而不是gitlab-runner,但它有自己的问题:错误:无法加载config stat /etc/gitlab-runner/config.toml:没有这样的文件或目录builds=0
在没有超级用户权限的情况下执行gitlab-runner时,没有任何配置文件问题。
https://stackoverflow.com/questions/60377532
复制相似问题