Deepin系统下GitLab Runner注册和基本环境配置
配置步骤如下:
第一步: 安装gitlab runner,
命令如下:
sudo apt-get install gitlab-runner
第二步: 启动Runner register 与 GitLab CI 进行绑定
sudo gitlab-ci-multi-runner register
Running in system-mode.
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://192.168.112.9:8080/
Please enter the gitlab-ci token for this runner:
U6kpy2Lfd2zgRQXCEzES
Please enter the gitlab-ci description for this runner:
CI-PC
Please enter the gitlab-ci tags for this runner (comma separated):
CI-PC
Whether to run untagged builds [true/false]:
[false]: true
Whether to lock Runner to current project [true/false]:
[false]:
Registering runner... succeeded runner=U6kpy2Lf
Please enter the executor: virtualbox, docker+machine, parallels, shell, ssh, docker-ssh+machine, kubernetes, docker, docker-ssh:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
上述命令行说明:
gitlab-ci-multi-runner register:执行注册命令
Please enter the gitlab-ci coordinator URL:输入 ci 地址
Please enter the gitlab-ci token for this runner:输入 ci token
Please enter the gitlab-ci description for this runner:输入 runner 名称
Please enter the gitlab-ci tags for this runner:设置 tag
Whether to run untagged builds:这里选择 true ,代码上传后会能够直接执行
Whether to lock Runner to current project:直接回车,不用输入任何口令
Please enter the executor:选择 runner 类型,文中选择shell
其中ci和ci token的值如下:
第三步: 设置gitlab-runner工作路径和访问用户
gitlab-runner安装完毕后会自动创建一个gitlab-runner账户. 在ubuntu系统下其默认工作路径在/home/gitlab-runner, 默认访问者为gitlab-runner. 在deepin系统下其默认工作路径在/var/lib/gitlab-runner, 默认访问者为gitlab-runner. 由于/var/lib/gitlab-runner访问权限的限制, 需要做一下修改:
首先, 需要更改/var/lib/gitlab-runner的文件夹权限, 命令如下:
sudo chown lzh:lzh -R /var/lib/gitlab-runner
说明: 上述命令中lzh是当前用户名称, 即使用当前用户访问gitlab-runner文件夹.
其次, 设置gitlab-runner的工作路径为/var/lib/gitlab-runner, 使用者为lzh(当前用户名称), 命令如下:
sudo gitlab-runner install --user=lzh --working-directory=/var/lib/gitlab-runner
可通过如下命令查看上述修改内容:
sudo deepin-editor /etc/systemd/system/gitlab-runner.service
第四步: 启动gitlab-runner服务
命令如下:
sudo gitlab-runner start
可看到gitlab仓库中runner,如下图所示: