centos安装使用gitlab

安装gitlab必要的依赖

注: gitlab 非常占内存,鄙人至少使用3g才够用

sudo yum install -y curl policycoreutils-python openssh-server
sudo systemctl enable sshd
sudo systemctl start sshd

# sudo firewall-cmd --permanent --add-service=http
# sudo systemctl reload firewalld

安装Postfix发送邮件通知

sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix

添加gitlab仓库安装包

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

安装gitlab包

# 注意这里的80端口 默认是80端口 如果想改访问端口请在这里配置
sudo EXTERNAL_URL="http://gitlab.matosiki.site:80" yum install -y gitlab-ee

浏览主机名并登陆

http://192.168.132:80
输入初始密码 matosiki
使用 root matosiki登录

邮箱配置

vi /etc/gitlab/gitlab.rb
gitlab_rails['gitlab_email_from'] = "matosiki_hz@163.com"
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "matosiki_hz@163.com"
gitlab_rails['smtp_password'] = "1234qwer"
gitlab_rails['smtp_authentication'] = true
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab-ctl reconfigure
gitlab-ctl restart

GitLab CI/CD 持续集成开发

  1. .gitlab-ci.yml 文件到项目根目录并提交到仓库
  2. 配置Runner

进入项目配置 /gitlab-springboot/settings/ci_cd#js-runners-settings

看到手动安装的步骤:
注意url :http://192.168.10.137/ 注册令牌 yyNGcR9sqVLKwDqUD4g_
进入gitlab机器中输入命令行

# 安装 gitlba Runner
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash
sudo yum install gitlab-ci-multi-runner

## 完成测试
gitlab-ci-multi-runner

##注册
gitlab-ci-multi-runner register
# 注意这是填写上面的url
http://192.168.10.137/
## 注意这里填写上面的令牌
yyNGcR9sqVLKwDqUD4g_
## tags (用逗号分隔)
gitlab,runnner,集成,开发,测试
## 描述
my gitlab runner 一起干活
## 选择执行器 选择简单的shell
shell


## 验证启动是否成功
sudo gitlab-runner verify

## 启动runner 刷新gtilab网页 下方可以看到刚刚添加的runner
sudo gitlab-runner run

参考文档

gitlab官方文档

linux手动安装runnner

仓库选择安装runnner

runnner-register

runnner-executors

本文总阅读量