在 CentOS 上“集成 GitLab”通常指安装并部署 GitLab(CE/EE),或者将 GitLab 与其他系统(如 Jenkins、LDAP、Nginx)集成。下面我分两种常见场景说明。
sudo yum install -y curl policycoreutils openssh-server openssh-clients
sudo systemctl enable sshd
sudo systemctl start sshd
防火墙:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ce
如果是本机测试,可写 IP:
sudo EXTERNAL_URL="http://192.168.1.100" yum install -y gitlab-ce
sudo gitlab-ctl reconfigure
sudo gitlab-ctl status
http://服务器IPcat /etc/gitlab/initial_root_password
GitLab CI 示例(.gitlab-ci.yml):
stages:
- build
- deploy
build:
stage: build
script:
- mvn package
deploy:
stage: deploy
script:
- scp target/app.jar user@server:/opt/app
修改:
/etc/gitlab/gitlab.rb
gitlab_rails['ldap_enabled'] = true
gitlab_rails['ldap_servers'] = YAML.load <<-EOS
main:
label: 'LDAP'
host: 'ldap.example.com'
port: 389
uid: 'sAMAccountName'
bind_dn: 'cn=admin,dc=example,dc=com'
password: 'password'
base: 'dc=example,dc=com'
EOS
sudo gitlab-ctl reconfigure
GitLab 自带 Nginx,若需外部 Nginx:
nginx['enable'] = false
外部 Nginx 示例:
location / {
proxy_pass http://127.0.0.1:8080;
}
sudo gitlab-ctl stop
减少 sidekiq / puma 进程数
sudo vim /etc/gitlab/gitlab.rb
external_url 'http://new-domain.com'
sudo gitlab-ctl reconfigure
sudo gitlab-rake gitlab:backup:create
如果你指的是:
可以告诉我你的具体使用场景,我可以给你更精确的方案。