GitLab 代码管理平台部署及使用
一、前置条件
1.yum 安装依赖包
yum install -y curl policycoreutils policycoreutils-python-utils openssh-server openssh-clients
2、开启 sshd 和邮件服务
systemctl enable sshd
systemctl start sshdyum install -y postfix
systemctl start postfix
systemctl enable postfix
二、部署 GitLab
本次安装使用:gitlab-ce-17.1.1-ce.0.el7.x86_64.rpm
2.1 下载gitlab-ce 的 rpm 软件包
wget --no-check-certificate https://packages.gitlab.com/gitlab/gitlab-ce/el/7/x86_64/gitlab-ce-17.1.1-ce.0.el7.x86_64.rpm
2.2 rpm 安装 gitlab
rpm -ivh gitlab-ce-17.1.1-ce.0.el7.x86_64.rpm
如下图安装成功
2.3 修改 GitLab 配置
cp /etc/gitlab/gitlab.rb /etc/gitlab/gitlab.rb.default
vim /etc/gitlab/gitlab.rb
访问地址
#配置用户访问gitlab的访问/下载代码地址
external_url 'http:/192.168.159.129'
邮箱配置
[root@localhost ~]# vim /etc/gitlab/gitlab.rb
#开启邮件配置
gitlab_rails['smtp_enable'] = true
#修改为对应的邮箱服务器域名(我这里的是腾讯企业邮箱)
gitlab_rails['smtp_address'] = "smtp.qq.com"
#对应的端口协议
gitlab_rails['smtp_port'] = 465
#登录邮箱的用户名
gitlab_rails['smtp_user_name'] = "1063410061@qq.com"
#登录邮箱的密码(其他的邮箱为授权码,例如QQ、163邮箱)
gitlab_rails['smtp_password'] = "qiang817."
#修改为对应的邮箱服务器域名
gitlab_rails['smtp_domain'] = "qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['smtp_pool'] = false
#gitlab发送邮件的发送人
gitlab_rails['gitlab_email_from'] = '1063410061@qq.com'
2.4 重载 GitLab 配置
gitlab-ctl reconfigure
启动
gitlab-ctl start
停止
gitlab-ctl stop
重启
gitlab-ctl restart
开机启动
systemctl enable gitlab-runsvdir.service
禁止开机启动
systemctl disable gitlab-runsvdir.service
2.5 访问 GitLab
默认用户:root
密码:需要查看 /etc/gitlab/initial_root_password
文件
cat /etc/gitlab/initial_root_password# WARNING: This value is valid only in the following conditions
# 1. If provided manually (either via `GITLAB_ROOT_PASSWORD` environment variable or via `gitlab_rails['initial_root_password']` setting in `gitlab.rb`, it was provided before database was seeded for the first time (usually, the first reconfigure run).
# 2. Password hasn't been changed manually, either via UI or via command line.
#
# If the password shown here doesn't work, you must reset the admin password following https://docs.gitlab.com/ee/security/reset_user_password.html#reset-your-root-password.Password: scT2TYkUtjHPX9wS48thq/HRHE1CMmoEyYPTKUcBG/E=# NOTE: This file will be automatically deleted in the first reconfigure run after 24 hours.
三、GitLab 设置中文
如下图所示,点击用户头像,偏好设置中,找到本地化语言
四、GitLab 基础使用
Groups:对应公司项目,某个项目中可能会有不同数量的服务
projects:对应项目中的某个服务
users:对应公司的开发人员
4.1 GitLab 创建空白项目
4.2 创建秘钥
在 window 中任一文件夹中的右键,选择 在终端中打开,运行 ssh-keygen -t rsa 生成一个随机秘钥
秘钥如上图所示位置,把 id_rsa.pub 文件内容配置到 GitLab 中
五、GitLab 的基本使用
在GitLab 上创建一个项目
进入本地项目目录,按如下操作
5.1 初始化 本地Git仓库
git init
5.2 把 Git本地仓库 与远程仓库关联
git remote add origin http://192.168.159.129/ruoyi/crm.git
5.3 把文件加入暂存区
git commit -m "first commit"
5.4 上传代码
git push -u origin master