1.版本控制介绍
版本控制针对开发过程中的各种程序代码,配置文件,说明文档,文件的变更的合理管理,核心是软件配置的管理。
版本控制主要的功能是记录文件内的变更,文件的改变,文件的版本号都将增加,除了记录版本变更外,版本控制的另一个重要功能是和软件开发协同作业,版本控制可以有效的解决版本的同步以及不同开发者之间的开发通信问题,提高协同开发的效率,不同版本软件的bug错误可以通过版本控制中对端分支与合并的方法有效解决。
版本控制工具
Gitlab文档
gitlab
subversion
2.gitlab部署
最新linux环境
#安装epel源
[root@localhost ~]# yum -y install epel-release
#安装git
[root@localhost ~]# yum -y install git
#安装依赖包
[root@localhost ~]# yum list all|grep policycoreutils|grep python //该包会变动
policycoreutils-python-utils.noarch 2.9-16.el8
[root@localhost ~]# yum -y install curl openssh-server openssh-clients postfix cronie policycoreutils-python-utils
#开启邮箱服务
[root@localhost src]# systemctl enable --now postfix
Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service.
#下载gitlab软件包
[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget https://mirrors.bfsu.edu.cn/gitlab-ce/yum/el8/gitlab-ce-14.3.2-ce.0.el8.x86_64.rpm
[root@localhost src]# ls
debug gitlab-ce-14.3.2-ce.0.el8.x86_64.rpm kernels
#安装gitlab rpm包
[root@localhost src]# rpm -ivh gitlab-ce-14.3.2-ce.0.el8.x86_64.rpm
警告:gitlab-ce-14.3.2-ce.0.el8.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID f27eab47: NOKEY
Verifying... ################################# [100%]
准备中... ################################# [100%]
正在升级/安装...
1:gitlab-ce-14.3.2-ce.0.el8 ################################# [100%]
It looks like GitLab has not been configured yet; skipping the upgrade script.
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __ \
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/
Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance. //显示请配置你的url
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file. //配置文件
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure //配置完,运行此命令
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=14-3
#配置gitlab的文件
[root@localhost src]# vim /etc/gitlab/gitlab.rb
external_url 'http://192.168.136.242' //改成你的本机ip
#以下是,一个邮箱的方式通知其它人员(可选/可不选)
gitlab_ralis['smtp_enable'] = true
gitlab_ralis['smtp_address'] = "smtp.qq.com"
gitlab_ralis['smtp_port'] = 465
gitlab_ralis['smtp_user_name'] = "你的qq邮箱@qq.com"
gitlab_ralis['smtp_password'] = "xccuhvjkxmeffdjb" #qq邮箱客户端授权码
gitlab_ralis['smtp_domain'] = "qq.com"
gitlab_ralis['smtp_authentication'] = :login
gitlab_ralis['smtp_enable_starttls_auto'] = true
gitlab_ralis['smtp_tls'] = true
gitlab_ralis['smtp_email_from'] = "你的qq邮箱@qq.com"
user["git_user_email"] = "你的qq邮箱@qq.com"
[root@localhost src]# gitlab-ctl reconfigure
Starting Chef Infra Client, version 15.17.4
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
- gitlab (0.0.1)
- package (0.1.0)
- logrotate (0.1.0)
- postgresql (0.1.0)
- redis (0.1.0)
- monitoring (0.1.0)
- registry (0.1.0)
- mattermost (0.1.0)
#观察到的端口
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 1024 127.0.0.1:9187 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:9093 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:9100 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:9229 0.0.0.0:*
LISTEN 0 128 127.0.0.1:9168 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:8080 0.0.0.0:*
LISTEN 0 511 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 127.0.0.1:8082 0.0.0.0:*
LISTEN 0 128 127.0.0.1:9236 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:3000 0.0.0.0:*
LISTEN 0 100 127.0.0.1:25 0.0.0.0:*
LISTEN 0 511 0.0.0.0:8060 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:9121 0.0.0.0:*
LISTEN 0 1024 127.0.0.1:9090 0.0.0.0:*
LISTEN 0 1024 *:9094 *:*
LISTEN 0 128 [::1]:9168 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
#关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
#查看github版本
[root@localhost ~]# head -1 /opt/gitlab/version-manifest.txt
gitlab-ce 14.3.2
#查看gitlab默认密码
[root@localhost ~]# cat /etc/gitlab/initial_root_password
Password: JMJQNeTfLhpA5O0RpTavm6Fa/dOnr/K1G+5KejOJ4UI=
#忘记密码,破解密码
[root@localhost ~]# gitlab-rails console -e production //进入gitlab控制台
--------------------------------------------------------------------------------
Ruby: ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux]
GitLab: 14.3.2 (92acfb1b8a9) FOSS
GitLab Shell: 13.21.1
PostgreSQL: 12.7
irb(main):011:0> user = User.where(id: 1).first //用户是对于id=1的超级管理员
=> #<User id:1 @root>
irb(main):012:0> user.password = 'gitlab@@@' //设置密码,必须是八位以上
=> "gitlab@@@"
irb(main):013:0> user.password_confirmation = 'gitlab@@@' //再次确认密码
=> "gitlab@@@"
irb(main):014:0> user.save! //保存
Enqueued ActionMailer::MailDeliveryJob (Job ID: 45eb0c23-ffac-4eea-8eb2-274f003f18cf) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", {:args=>[#<GlobalID:0x00007ff48ea91de0 @uri=#<URI::GID gid://gitlab/User/1>>]}
=> true
gitlab以及git常用命令
gitlab-ctl start|stop|restart|status #gitlab服务开启关闭重启状态命令
gitlab-ctl reconfigure #重启配置
gitlab-ctl tail nginx #查组件日志
git config --global user.name "xx" #设置全局用户名
git config --global user.email "xxx@xxx.com" #设置全局邮箱
git clone xxx #克隆项目
git add xxx #文件添加到本地仓库
git commit -m "xxx" #提交项目到本地仓库,-m描述信息
下载gitlab最新安装包:https://mirrors.bfsu.edu.cn/gitlab-ce/yum/el8/(外国语学校镜像源)
访问gitlabweb界面
3.gitlab界面创建用户和组
web界面管理介绍
用户操作
换另一个浏览器再次访问,用tom用户进行登录,会提示重新设置一个新的密码
用户的禁用以及再次编辑,一般情况下不会删除某个用户
创建组
添加用户到组
4.gitlab项目的介绍
4.1创建项目
4.2项目克隆到linux目录下(重要)
#项目拉到本地服务器
[root@localhost opt]# pwd
/opt
[root@localhost opt]# git clone http://192.168.136.242/it/gram.git
[root@localhost opt]# ls
gitlab gram
[root@localhost opt]# cd gram/
[root@localhost gram]# git switch -c master //切换一个主分支
#Git全局配置
[root@localhost gram]# git config --global user.name "Administrator"
[root@localhost gram]# git config --global user.email "admin@example.com"
#添加一个内容,因为项目之前没有东西
[root@localhost gram]# touch README.md
[root@localhost gram]# git add README.md
[root@localhost gram]# git commit -m "add README"
#本地的内容传到gitlab上
[root@localhost gram]# git push -u origin master
Username for 'http://192.168.136.242': root
Password for 'http://root@192.168.136.242':
4.3发布,发版,上线的流程(生产环境)
发布需求由运营人员提出
开发人员按照需求开发代码,可以加需求,提交变更单(开发组长签字)
测试人员进行测试
1. 有问题:打回修复代码 2. 无问题:**让测试人员签字**(避免背锅)
运维人员
1.评估
2.汇报 (邮件方式还是避免背锅)
CTO 首席技术总监 (服从cto即可)
以上是大厂的流程