在gitlab CI中gitlab运行程序选择了错误的执行程序 [英] In gitlab CI the gitlab runner choose wrong executor

查看:321
本文介绍了在gitlab CI中gitlab运行程序选择了错误的执行程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Gitlab管道安装程序存在以下问题.

I have the following problem with my Gitlab Pipeline Setup.

我意识到在bash中显示了"shellRunner",但是在.yml文件中,我使用了"tags:-docker".如果我重新运行该工作,有时它会运行并使用合适的运行器,但大多数时候却不行.

I recognized that in the bash there is shown "shell runner" but in the .yml file I used "tags: -docker". If I re-run the job, sometimes it works and uses the right runner, but most of the time not.

这是bash的输出:

使用gitlab-runner 10.8.0(079cad9e)运行在AWS XYZ C444133A上使用Shell执行器...在ip-xyz上运行...正在获取更改...HEAD现在位于eb4ea13 xyz:删除了数据重试队列正在将e0461c05检出为后端测试...跳过Git子模块设置正在检查高速缓存中的default-1 ...成功提取缓存$ echo这是在每个步骤之前完成的"这是在每个步骤之前完成的$ echo更新容器内的服务器软件"更新容器内的服务器软件$ apt-get更新-y正在阅读包裹清单...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文件中的工作:

This is the job in the gitlab-ci.yml file:

backend_test:图片:node:6服务:-名称:mysql:5.7阶段:测试变量:MYSQL_ROOT_PASSWORD:xyzMYSQL_DATABASE:xyzMYSQL_USER:xyzMYSQL_PASSWORD:xyzDBDIALECT:mysql数据库数据库:xyzDBUSER:xyzDBPASSWORD:xyzDBHOST:mysqlDBPORT:"3306"脚本:-回显更新容器内的服务器软件"-易于获取更新-y-易于升级-y-回显安装依赖项"-CD API/后端/-ls -lah-npm安装-回显开始测试"-NODE_ENV = test npm运行测试代码覆盖率标签:-码头工人

有什么想法吗?

推荐答案

@edit:来自此处:

标签用于从允许运行该项目的所有Runner列表中选择特定的Runner.

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

正如评论中所解决的那样,您执行的外壳程序必须已标记有 docker 标记,这导致他被选为工作的执行者.

As resolved in the comments, your shell executed must have been tagged with the docker tag, which resulted in him being picked as the executor for the job.

这是我的旧答案:

您正在使用Shell执行程序,并且从此处:

You are using a shell executor, and from here:

Shell executor是一个简单的执行器,可让您在安装了Runner的计算机上本地执行构建.
...
如果GitLab Runner是通过.deb或.rpm官方软件包在Linux上安装的,则安装程序将尝试使用gitlab_ci_multi_runner用户.如果没有找到,它将创建一个gitlab-runner用户并使用它.....
在某些测试方案中,您的构建可能需要访问一些特权资源
...
通常,使用Shell执行程序运行测试是不安全的.这些作业在用户权限(gitlab-runner)下运行,并且可以窃取"该服务器上运行的其他项目中的代码.仅将其用于在您信任和拥有的服务器上运行构建.

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 命令的权限.您可以:

The commands your are running are executed as gitlab-runner user and don't have permissions to run apt-get command. You can:

  • 移至docker
  • 向用户gitlab-runner授予运行指定命令所需的权限.gitlab-runner可能在没有sudo的情况下运行apt-get ,而且他需要npm的烫发安装并运行npm.
  • 将sudo nopasswd授予用户gitlab-runner.将 gitlab-runner ALL =(ALL)NOPASSWD:ALL (或类似内容)添加到已安装gitlab-runner的计算机上的/etc/sudoers中,并更改行 apt-get update sudo apt-get update ,它将以特权用户(root)的身份执行它们.
  • move to docker
  • grant user gitlab-runner the permissions he needs to run specified commands. gitlab-runner may run apt-get without sudo, also he will need perms for npm install and npm run.
  • grant sudo nopasswd to user gitlab-runner. Add gitlab-runner ALL=(ALL) NOPASSWD: ALL (or similar) to /etc/sudoers on the machine gitlab-runner is installed and change the lines apt-get update to sudo apt-get update, which will execute them as privileged user (root).

这篇关于在gitlab CI中gitlab运行程序选择了错误的执行程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆