4月 17, 2020 - Linux    centos6.9安装gitlab-runner已关闭评论

centos6.9安装gitlab-runner

1:下载gitlab-runner

sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64

2:添加可执行权限

sudo chmod +x /usr/local/bin/gitlab-runner

3.创建gitlab Ci 用户

sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash

4.安装并运行服务

sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
sudo gitlab-runner start

如果希望gitlab-runner的工作目录非/home/gitlab-runner,可以在install时修改--working-directory参数。

5.问题

5.1若working-directory没有权限创建目录

则修改目录权限:

sudo chown -R gitlab-runner:gitlab-runner web-gitlab-runner

5.2 Missing /usr/local/bin/gitlab-runner. Uploading artifacts is disabled.

/usr/local/bin/gitlab-runner所属用户改为install传入的--user

sudo chown gitlab-runner:gitlab-runner /usr/local/bin/gitlab-runner

5.3 sudo 执行提示 Command not found

在普通用户下运行命令可行,切换到root用户依然可行,但在普通用户下使用sudo执行时,提示Command not found。

修改/etc/sudoers文件,找到类似下面的一行:

Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin  

将要执行的命令所在的目录添加到后面,即可,如:

Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin  

评论被关闭。