gpt4 book ai didi

linux - 在 gitlab CI 中,gitlab runner 选择了错误的执行者

转载 作者:太空宇宙 更新时间:2023-11-04 09:14:04 25 4
gpt4 key购买 nike

我的 Gitlab 管道设置有以下问题。

我发现在 bash 中显示了“shell runner”,但在 .yml 文件中我使用了“tags: -docker”。如果我重新运行该工作,有时它会工作并使用正确的运行者,但大多数时候不会。

这是 bash 输出:

使用 gitlab-runner 10.8.0 (079cad9e) 运行
在 aws-xyz c444133a 上
使用 Shell 执行器...
在 ip-xyz 上运行...
正在获取更改...
HEAD 现在位于 eb4ea13 xyz:删除了数据重试队列
正在检查 e0461c05 作为后端测试...
跳过 Git 子模块设置
正在检查默认 1 的缓存...
成功提取缓存
$ echo "这是在每一步之前完成的"
这是在每一步之前完成的
$ echo "更新容器内的服务器软件"
更新容器内的服务器软件
$ apt-get 更新-y
阅读包裹 list ...
W: 目录/var/lib/apt/lists/partial 的 chmod 0700 失败 - SetupAPTPartialDirectory(1:不允许操作)
E: 无法打开锁文件/var/lib/apt/lists/lock - 打开(13:权限被拒绝)
E: 无法锁定目录/var/lib/apt/lists/
W:取消链接文件/var/cache/apt/pkgcache.bin 时出现问题 - RemoveCaches(13:权限被拒绝)
W:取消链接文件/var/cache/apt/srcpkgcache.bin 时出现问题 - RemoveCaches(13:权限被拒绝)
在脚本之后运行...
$ echo "这是在每一步之后完成的"
这是在每一步之后完成的
错误:作业失败:退出状态 1

这是gitlab-ci.yml文件中的作业:

后端测试:
图片:节点:6
服务:
- 名称:mysql:5.7
阶段:测试
变量:
MYSQL_ROOT_PASSWORD: xyz
MYSQL_DATABASE: xyz
MYSQL_USER: xyz
MYSQL_PASSWORD: xyz
数据库方言:mysql
数据库数据库:xyz
DBUSER: xyz
数据库密码:xyz
数据库主机:mysql
数据库端口:“3306”
脚本:
- echo “更新容器内的服务器软件”
- 易于获取更新-y
-apt-get升级-y
- echo “安装依赖项”
- cd api/后端/
- ls -lah
- npm 安装
- echo "开始测试"
- NODE_ENV=test npm run test-code-coverage
标签:
- docker

有什么想法吗?

最佳答案

@编辑:来自here :

tags is used to select specific Runners from the list of all Runners that are allowed to run this project.

如评论中所述,您执行的 shell 必须使用 docker 标记,这导致他被选为该作业的执行者。

这是我的旧答案:

您正在使用 shell 执行器,并且来自 here :

Shell executor is a simple executor that allows you to execute builds locally to the machine that the Runner is installed
...
If GitLab Runner is installed on Linux from the official .deb or .rpm packages, the installer will try to use the gitlab_ci_multi_runner user if found. If it is not found, it will create a gitlab-runner user and use this instead. ....
In some testing scenarios, your builds may need to access some privileged resources
...
Generally it's unsafe to run tests with shell executors. The jobs are run with the user's permissions (gitlab-runner) and can "steal" code from other projects that are run on this server. Use it only for running builds on a server you trust and own.

您正在运行的命令是作为 gitlab-runner 用户执行的,没有运行 apt-get 命令的权限。您可以:

  • 移动到 docker
  • 授予用户 gitlab-runner 运行指定命令所需的权限。 gitlab-runner 可能 run apt-get without sudo ,他还需要 npm install 和 npm run 的权限。
  • 将 sudo nopasswd 授予用户 gitlab-runner。将 gitlab-runner ALL=(ALL) NOPASSWD: ALL (或类似的)添加到安装了 gitlab-runner 的机器上的/etc/sudoers 并更改行 apt-get updatesudo apt-get update,这将以特权用户 (root) 身份执行它们。

关于linux - 在 gitlab CI 中,gitlab runner 选择了错误的执行者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50678061/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com