江明涛的博客
Centos 7 安装 gitlab runner
Centos 7 安装 gitlab runner

Centos 7 安装 gitlab runner

参考:https://docs.gitlab.com/runner/install/linux-manually.html

安装方法 1

# 添加yum源
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh | sudo bash
# 安装
yum install -y gitlab-runner
# 查看版本
gitlab-runner -v

安装方法 2

# centos 7 为  Linux x86-64
sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64

# 设置安装目录可执行
sudo chmod +x /usr/local/bin/gitlab-runner

# 直接使用 root 用户权限运行 gitlab-runner (或者其他用户,看需求)
sudo gitlab-runner install --user=root --working-directory=/home/gitlab-runner
#启动
sudo gitlab-runner start

# 如果提示命令  command not found  需要配置环境
# 添加软链接
ln -s -f /usr/local/bin/gitlab-runner /usr/bin/gitlab-runner

# 查看版本
gitlab-runner -v

注册 gitlab-runner
通过管理员登录 gitlab —- 管理中心—- 概况 —- Runner 查看需要注册的 URL与 Token(令牌)

配置注册信息 gitlab-runner register

[root@localhost ~]#  gitlab-runner register
Running in system-mode.                            
# 引导会让你输入gitlab的url,输入自己的url,例如http://gitlab.example.com/                           
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://xxx.xxx.xxx:xxx/
# 引导会让你输入token,去相应的项目下找到token,例如xrjc3tWcdQpLcEwoYzkU
Please enter the gitlab-ci token for this runner:
xrjc3tWcdQpLcEwoYzkU
# 输入描述
Please enter the gitlab-ci description for this runner:
[localhost.localdomain]: develop
# 引导会让你输入tag,一个项目可能有多个runner,是根据tag来区别runner的,输入若干个就好了,比如web,hook,deploy,develop
Please enter the gitlab-ci tags for this runner (comma separated):
develop
# 是否运行未标记的版本
Whether to run untagged builds [true/false]:
[false]: false
# 是否将运行程序锁定到当前项目
Whether to lock Runner to current project [true/false]:
[false]: true
Registering runner... succeeded                     runner=xrjc3tWc
#  引导会让你输入executor,这个是要用什么方式来执行脚本,图方便输入shell就好了
Please enter the executor: shell, ssh, docker+machine, docker, docker-ssh, parallels, virtualbox, docker-ssh+machine, kubernetes:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded! 

启用CI/CD

命令

# 运行
gitlab-runner run
# 启动
gitlab-runner start
# 重启
gitlab-runner restart
# 通过name 取消注册
gitlab-runner unregister --name develop
# 删除所有注册runner
gitlab-runner unregister --all-runners

上次更新时间 20 3 月, 2023 at 09:27 上午