在 gitlab CI 中,gitlab runner 选择了错误的执行者
In gitlab CI the gitlab runner choose wrong executor
我的 Gitlab 管道设置有以下问题。
我发现在 bash 中显示了 "shell runner",但在 .yml 文件中我使用了 "tags: -docker"。如果我重新 运行 作业,有时它会工作并使用正确的 运行ner,但大多数时候不会。
bash 输出:
Running with gitlab-runner 10.8.0 (079cad9e)
on aws-xyz c444133a
Using Shell executor...
Running on ip-xyz...
Fetching changes...
HEAD is now at eb4ea13 xyz: removed data retry queue
Checking out e0461c05 as backend-tests...
Skipping Git submodules setup
Checking cache for default-1...
Successfully extracted cache
$ echo "this is done BEFORE each step"
this is done BEFORE each step
$ echo "updating server software inside container"
updating server software inside container
$ apt-get update -y
Reading package lists...
W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)
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)
Running after script...
$ echo "this is done AFTER each step"
this is done AFTER each step
ERROR: Job failed: exit status 1
这是gitlab-ci.yml文件中的作业:
backend_test:
image: node:6
services:
- name: mysql:5.7
stage: test
variables:
MYSQL_ROOT_PASSWORD: xyz
MYSQL_DATABASE: xyz
MYSQL_USER: xyz
MYSQL_PASSWORD: xyz
DBDIALECT: mysql
DBDATABASE: xyz
DBUSER: xyz
DBPASSWORD: xyz
DBHOST: mysql
DBPORT: "3306"
script:
- echo "updating server software inside container"
- apt-get update -y
- apt-get upgrade -y
- echo "installing dependencies"
- cd api/backend/
- ls -lah
- npm install
- echo "start testing"
- NODE_ENV=test npm run test-code-coverage
tags:
- 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-运行ner 他需要 运行 指定命令的权限。 gitlab-运行ner 可能 run apt-get without sudo,他还需要 npm install 和 npm 运行.
的权限
- 向用户 gitlab-运行ner 授予 sudo nopasswd。在安装了 gitlab-运行ner 的机器上将
gitlab-runner ALL=(ALL) NOPASSWD: ALL
(或类似的)添加到 /etc/sudoers,并将行 apt-get update
更改为 sudo apt-get update
,这将执行它们特权用户 (root).
我的 Gitlab 管道设置有以下问题。
我发现在 bash 中显示了 "shell runner",但在 .yml 文件中我使用了 "tags: -docker"。如果我重新 运行 作业,有时它会工作并使用正确的 运行ner,但大多数时候不会。
bash 输出:
Running with gitlab-runner 10.8.0 (079cad9e)
on aws-xyz c444133a
Using Shell executor...
Running on ip-xyz...
Fetching changes...
HEAD is now at eb4ea13 xyz: removed data retry queue
Checking out e0461c05 as backend-tests...
Skipping Git submodules setup
Checking cache for default-1...
Successfully extracted cache
$ echo "this is done BEFORE each step"
this is done BEFORE each step
$ echo "updating server software inside container"
updating server software inside container
$ apt-get update -y
Reading package lists...
W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: Operation not permitted)
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)
Running after script...
$ echo "this is done AFTER each step"
this is done AFTER each step
ERROR: Job failed: exit status 1
这是gitlab-ci.yml文件中的作业:
backend_test:
image: node:6
services:
- name: mysql:5.7
stage: test
variables:
MYSQL_ROOT_PASSWORD: xyz
MYSQL_DATABASE: xyz
MYSQL_USER: xyz
MYSQL_PASSWORD: xyz
DBDIALECT: mysql
DBDATABASE: xyz
DBUSER: xyz
DBPASSWORD: xyz
DBHOST: mysql
DBPORT: "3306"
script:
- echo "updating server software inside container"
- apt-get update -y
- apt-get upgrade -y
- echo "installing dependencies"
- cd api/backend/
- ls -lah
- npm install
- echo "start testing"
- NODE_ENV=test npm run test-code-coverage
tags:
- 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-运行ner 他需要 运行 指定命令的权限。 gitlab-运行ner 可能 run apt-get without sudo,他还需要 npm install 和 npm 运行. 的权限
- 向用户 gitlab-运行ner 授予 sudo nopasswd。在安装了 gitlab-运行ner 的机器上将
gitlab-runner ALL=(ALL) NOPASSWD: ALL
(或类似的)添加到 /etc/sudoers,并将行apt-get update
更改为sudo apt-get update
,这将执行它们特权用户 (root).