在 GitLab 中集成 CentOS 通常指两种场景:
1️⃣ 在 CentOS 上安装 GitLab(GitLab 服务器运行在 CentOS)
2️⃣ GitLab CI/CD 集成 CentOS(作为构建/部署环境)
下面分别说明,你可以按需要选择。
# 更新系统
sudo yum update -y
# 安装依赖
sudo yum install -y curl policycoreutils openssh-server perl
开启 SSH:
sudo systemctl enable sshd
sudo systemctl start sshd
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
企业版(EE)可免费使用,也可用
gitlab-ce(社区版)
sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ee
✅ 如果你是本机测试:
sudo EXTERNAL_URL="http://localhost" yum install -y gitlab-ee
sudo gitlab-ctl reconfigure
访问:
http://服务器IP
首次登录会要求设置 root 密码
sudo gitlab-ctl status
sudo gitlab-ctl restart
sudo gitlab-ctl tail
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash
sudo yum install -y gitlab-runner
sudo gitlab-runner register
依次输入:
https://gitlab.com)centos)shell 或 docker)sudo gitlab-runner start
.gitlab-ci.yml 示例stages:
- build
build_on_centos:
stage: build
tags:
- centos
script:
- cat /etc/centos-release
- echo "Build on CentOS"
✅ 推荐使用:
GitLab 官方仍支持这些系统。
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload
| 集成方式 | 说明 |
|---|---|
| GitLab 安装在 CentOS | 自建 GitLab 服务器 |
| GitLab Runner 在 CentOS | CI/CD 构建/部署 |
| Webhook + CentOS | 自动化部署(较少用) |
如果你能具体说明:
我可以给你一套 完全贴合你环境的配置方案。