部署gitlab,模拟开发流程。
一、安装部署gitlab
机器内存大于等于4G
# 关闭防火墙、禁用SELinux
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# sed -i '/^SELINUX=/c SELINUX=disabled' /etc/selinux/config
[root@localhost ~]# setenforce 0
# 安装常用包
[root@localhost ~]# yum install -y curl policycoreutils-python openssh-server postfix
[root@localhost ~]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@localhost ~]# yum install git-all
[root@localhost ~]# git init
# 安装gitlab
[root@localhost ~]# yum install https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-15.0.0-ce.0.el7.x86_64.rpm -y
[root@localhost ~]# vim /etc/hosts
192.168.235.173 gitlab.zaxcloud.com
[root@localhost ~]# vim /etc/gitlab/gitlab.rb
external_url 'http://gitlab.zaxcloud.com' #32行
[root@localhost ~]# gitlab-ctl reconfigure #重启
[root@localhost ~]# gitlab-ctl status # 全都处于run的状态即可
[root@localhost ~]# more /etc/gitlab/initial_root_password #查看密码
在windows下修改Hosts,加上192.168.235.173 gitlab.zaxcloud.com
网页登录gitlab.zaxcloud.com
登录成功后可以修改密码,不然太长。
二、部署gitlab邮箱
[root@localhost ~]# vim /etc/gitlab/gitlab.rb
# 修改好后重新加载配置
[root@localhost ~]# gitlab-ctl reconfigure
测试配置是否成功
[root@localhost ~]# gitlab-rails console
Notify.test_email('邮箱@163.com', 'test mail', 'test mail').deliver_now
三、gitlab使用流程
- 账号申请
- 客户端安装
- SSH key使用
- 新建项目规则
- 项目检出check
- 创建分支branch
- 代码提交Commit
- 代码拉取Pull
- 代码推送Push
3-1.创建组
创建用户和管理员,在MENU的Admin里
改密码
3-2.添加用户到组,pm为管理员,tom为开发者
3-3.安装客户端
首先安装git,一直下一步即可
点开后运行git init
安装TortoiseGit
再安装汉化包
3-4.生成SSHkey
命令行创建
ssh-keygen -C 'mikasa19239982@163.com' -N '' -f ~/.ssh/id_rsa -q
cat ~/.ssh/id_rsa.pub
在任意文件夹下点击右键,选择 Git GUI Here。在弹出的程序中选择主菜单的【Help】→【Show SSH Key】
如果没有Key,则点击“Generate Key”生成一个SSH Key
3-5.Gitlab 配置SSH keys
到用户设置里的SHH Keys添加
3-6.新建一个项目
3-7.新建项目规则
项目经理制定开发计划–创建里程碑
切换到pm账号
项目经理制定开发计划–分配任务
3-8.项目检出
以tom为例: 这里只是需要把TortoiseGit设置网络里面的ssh客户端位置C:\Program Files\TortoiseGit\bin\TortoiseGitPlink.exe,修改成成git安装目录下的ssh.exe即可。不然拉取等操作时会提示需要输入密码。
3-9.拉取项目,创建分支和切换分支,并提交
[root@gitlab ~]# git clone git@gitlab.zaxcloud.com:dev/project.git
[root@gitlab project]# git branch index
[root@gitlab project]# git checkout index
[root@gitlab project]# echo "<h1> 首页 <h1>" > test.html
[root@gitlab project]# git push origin index
3-10.发出合并请求
登录tom
确认请求合并 pm登录后确认合并请求
关闭任务 pm关闭任务。