0
点赞
收藏
分享

微信扫一扫

centos7安装GitLab Runner

要在CentOS 7上安装GitLab Runner,请按照以下步骤操作:

1. 添加GitLab的官方仓库

打开终端并执行以下命令:

curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash

这个脚本会自动添加GitLab Runner的官方仓库到你的系统中。

2. 安装GitLab Runner

通过yum安装GitLab Runner:

sudo yum install gitlab-runner

3. 启动并激活GitLab Runner

安装完成后,启动GitLab Runner服务:

sudo systemctl start gitlab-runner

确保GitLab Runner在开机时自动启动:

sudo systemctl enable gitlab-runner

4. 注册GitLab Runner

在注册Runner之前,你需要从GitLab实例获得两个关键信息:

  • GitLab实例的URL(例如:https://gitlab.com/
  • 注册令牌(你可以在GitLab项目的Settings -> CI/CD下的Runners区域找到)

使用以下命令注册Runner:

sudo gitlab-runner register

在注册过程中,你要输入GitLab实例URL,注册令牌,描述(Runner的描述),标签(可以基于你的需求定义),执行器(推荐选择docker,如果你打算使用Docker运行CI/CD流程)。

例如:

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
https://gitlab.com/
Please enter the gitlab-ci token for this runner:
YOUR_REGISTRATION_TOKEN
Please enter the gitlab-ci description for this runner:
[hostname] my-runner
Please enter the gitlab-ci tags for this runner (comma separated):
my-runner,stable
Please enter the executor: docker, shell, docker-ssh, etc.:
docker

如果你选择了docker执行器,还需要指定Docker镜像:

Please enter the Docker image (eg. ruby:2.6):
alpine:latest

5. 验证GitLab Runner

注册完成后,你可以通过以下命令来检查Runner的状态:

sudo gitlab-runner status

或者在GitLab网站的项目设置中查看注册的Runner。

6. 更新GitLab Runner

为了保证你的Runner是最新版本,定期更新:

sudo yum update gitlab-runner

7. 配置和优化GitLab Runner(可选)

你可以编辑/etc/gitlab-runner/config.toml来进一步配置和优化你的Runner,比如设置并发数、缓存策略等。

完成以上步骤后,你就在CentOS 7上成功安装并注册了GitLab Runner。现在,Runner应当准备好从GitLab接收并执行作业了。

举报

相关推荐

0 条评论