项目案例之GitLab企业级代码管理仓库

一.安项GitLab

 主机名IP 备注特殊要求
 git01 192.168.200.136 GIT客户端 无
 girlab 192.168.200.140 GITLAB服务端 内存2G

 

 

 

 

 

GitLab国内源下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7

 1 ##初始环境
 2 [root@zhengweiqiang ~]# cat /etc/redhat-release 
 3 CentOS Linux release 7.5.1804 (Core)  4 [root@zhengweiqiang ~]# uname -r  5 3.10.0-862.el7.x86_64  6 [root@zhengweiqiang ~]# echo "git lab 127.0.0.1" >>/etc/hosts  7 [root@zhengweiqiang ~]# tail -1 /etc/hosts  8 git lab 127.0.0.1  9 [root@zhengweiqiang ~]# ls 10 anaconda-ks.cfg 11 gitlab-11-2-stable-zh.tar.gz #GITLAB 汉化包 12 gitlab-ce-11.2.3-ce.0.el7.x86_64.rpm #GITLAB 安装包 13 14 [root@zhengweiqiang ~]# yum localinstall gitlab-ce-11.2.3-ce.0.el 15 7.x86_64.rpm -y 16 17 重要说明:localinstall 利用yum 光盘源装依赖包 18 #初始化GitLab 只需执行一次 19 [root@zhengweiqiang ~]# gitlab-ctl reconfigure 20 #查看gitlab启动状态 21 [root@zhengweiqiang ~]# gitlab-ctl status 22 run: alertmanager: (pid 13022) 185s; run: log: (pid 13048) 183s 23 run: gitaly: (pid 12859) 201s; run: log: (pid 12871) 200s 24 run: gitlab-monitor: (pid 12990) 186s; run: log: (pid 13042) 184s 25 run: gitlab-workhorse: (pid 12844) 201s; run: log: (pid 12850) 20 26 1srun: logrotate: (pid 12172) 263s; run: log: (pid 12881) 200s 27 run: nginx: (pid 12118) 269s; run: log: (pid 12852) 201s 28 run: node-exporter: (pid 12332) 251s; run: log: (pid 12883) 199s 29 run: postgres-exporter: (pid 13037) 184s; run: log: (pid 13045) 1 30 84srun: postgresql: (pid 11641) 324s; run: log: (pid 12869) 200s 31 run: prometheus: (pid 13000) 185s; run: log: (pid 13046) 184s 32 run: redis: (pid 11512) 330s; run: log: (pid 12834) 201s 33 run: redis-exporter: (pid 12553) 239s; run: log: (pid 12993) 185s 34 run: sidekiq: (pid 11993) 281s; run: log: (pid 12870) 200s 35 run: unicorn: (pid 11926) 287s; run: log: (pid 12837) 201s 36 37 ##查看GitLab版本号 38 [root@zhengweiqiang ~]# cat /opt/gitlab/embedded/service/gitlab-r 39 ails/VERSION 11.2.3

 

宿主机输入http://IP地址就可以访问了

 

密码最少为8位

登陆管理员账号 : root  密码:66666666

登陆后,我们就可以选择如下功能使用了

 

安装GitLab中文补丁

GitLab中文社区:https://gitlab.com/xhang/gitlab/tree/11-2-stable-zh

#解压GitLab中文补丁包
[root@zhengweiqiang ~]# tar xf gitlab-11-2-stable-zh.tar.gz 
#查看系统已经安装的GitLab版本号 [root@zhengweiqiang ~]# cat /opt/gitlab/embedded/service/gitlab-r ails/VERSION 11.2.3 #查看解压后的补丁包版本号 [root@zhengweiqiang ~]# cat gitlab-11-2-stable-zh/VERSION 11.2.3 说明: 补丁版本号和安装的GitLab版本号需要一致 #备份英文版GitLab [root@zhengweiqiang ~]# cp -r /opt/gitlab/embedded/service/gitlab -rails{,.bak} #将中文补丁包的内容覆盖英文版 [root@zhengweiqiang ~]# /bin/cp -rf gitlab-11-2-stable-zh/* /opt/ gitlab/embedded/service/gitlab-rails/bin/cp: cannot overwrite non-directory ‘/opt/gitlab/embedded/ser vice/gitlab-rails/log’ with directory ‘gitlab-11-2-stable-zh/log’/bin/cp: cannot overwrite non-directory ‘/opt/gitlab/embedded/ser vice/gitlab-rails/tmp’ with directory ‘gitlab-11-2-stable-zh/tmp’ 说明: 此报错不用管,因为已经设置过root密码,登陆过,所以会报错。 #重新配置GitLab [root@zhengweiqiang ~]# gitlab-ctl reconfigure #重启 [root@zhengweiqiang ~]# gitlab-ctl restart

 重新刷新浏览器访问GitLab

 创建一个项目

修改GitLab配置文件/etc/gitlab/gitlab.rb

我们需要修改GitLab的默认访问域名

GitLab默认监听端口为80,但是企业中,这个端口经常被别的服务占用,所以我们需要更换端口

 1 [root@zhengweiqiang ~]# cat /etc/gitlab/gitlab.rb | sed -n '13p;9
 2 43p' external_url 'http://gitlab.example.com'
 3 # nginx['listen_port'] = nil
 4 [root@zhengweiqiang ~]# vim /etc/gitlab/gitlab.rb 
 5 [root@zhengweiqiang ~]# cat /etc/gitlab/gitlab.rb | sed -n '13p;9
 6 43p' external_url 'http://192.168.200.140:8888'
 7 nginx['listen_port'] = 8888
 8 #重新配置
 9 [root@zhengweiqiang ~]# gitlab-ctl reconfigure
10 
11 #重新启动GitLab
12 [root@zhengweiqiang ~]# gitlab-ctl restart

 

重新访问浏览器192.168.200.144:8888

 

尝试将本地仓库代码推送到私有GitLab

 1 #添加GitLab仓库管理
 2 [root@zhengweiqiang mycode]# git remote add test http://192.168.200.140:8888/root/yunjisuan.git
 3 [root@zhengweiqiang mycode]# git remote -v
 4 test    http://192.168.200.140:8888/root/yunjisuan.git (fetch)
 5 test    http://192.168.200.140:8888/root/yunjisuan.git (push)
 6 
 7 #推送本地仓库master分支到远程仓库GitLab上
 8 [root@zhengweiqiang mycode]# git add *
 9 [root@zhengweiqiang mycode]# git commit -m "测试一下"
10 ####省略输出#####
11 [root@zhengweiqiang mycode]# git push -u test master
12 Username for 'http://192.168.200.140:8888': root
13 Password for 'http://root@192.168.200.140:8888': 
14 Counting objects: 3, done.
15 Compressing objects: 100% (2/2), done.
16 Writing objects: 100% (3/3), 244 bytes | 0 bytes/s, done.
17 Total 3 (delta 0), reused 0 (delta 0)
18 To http://192.168.200.140:8888/root/yunjisuan.git
19  * [new branch]      master -> master
20 
21 #推送本地仓库标签V1.0到远程仓库GitLab上
22 [root@zhengweiqiang mycode]# git tag v1.0
23 [root@zhengweiqiang mycode]# git push -u test v1.0
24 Username for 'http://192.168.200.140:8888': root
25 Password for 'http://root@192.168.200.140:8888': 
26 Total 0 (delta 0), reused 0 (delta 0)
27 To http://192.168.200.140:8888/root/yunjisuan.git
28  * [new tag]         v1.0 -> v1.0
29 
30 #推送本地仓库Linux分支到远程仓库GitLab上
31 [root@zhengweiqiang mycode]# git branch linux
32 [root@zhengweiqiang mycode]# git checkout linux
33 Switched to branch 'linux'
34 #切换到linux分支
35 [root@zhengweiqiang mycode]# git branch
36 * linux
37   master
38 #添加一个文件
39 [root@zhengweiqiang mycode]# touch linun.txt
40 [root@zhengweiqiang mycode]# git add *
41 [root@zhengweiqiang mycode]# git commit -m "分支第一次"
42 [linux b2e4ca5] 分支第一次
43  1 file changed, 0 insertions(+), 0 deletions(-)
44  create mode 100644 linun.txt
45 
46 [root@zhengweiqiang mycode]# git push -u test linux
47 Username for 'http://192.168.200.140:8888': root
48 Password for 'http://root@192.168.200.140:8888': 
49 Counting objects: 2, done.
50 Compressing objects: 100% (2/2), done.
51 Writing objects: 100% (2/2), 256 bytes | 0 bytes/s, done.
52 Total 2 (delta 1), reused 0 (delta 0)
53 remote: 
54 remote: To create a merge request for linux, visit:
55 remote:   http://192.168.200.140:8888/root/yunjisuan/merge_reques
56 ts/new?merge_request%5Bsource_branch%5D=linuxremote: 
57 To http://192.168.200.140:8888/root/yunjisuan.git
58  * [new branch]      linux -> linux

 

 尝试在本地仓库克隆GitLab的项目Linux分支到本地仓库

 1 #创建测试目录
 2 [root@zhengweiqiang mycode]# mkdir -p /test
 3 [root@zhengweiqiang mycode]# cd /test/
 4 #克隆远程仓库分支Linux
 5 [root@zhengweiqiang test]# git clone -b linux http://192.168.200.
 6 140:8888/root/yunjisuan.git
 7 Cloning into 'yunjisuan'...
 8 Username for 'http://192.168.200.140:8888': root
 9 Password for 'http://root@192.168.200.140:8888': 
10 remote: Enumerating objects: 5, done.
11 remote: Counting objects: 100% (5/5), done.
12 remote: Compressing objects: 100% (4/4), done.
13 remote: Total 5 (delta 1), reused 0 (delta 0)
14 Unpacking objects: 100% (5/5), done.
15 Checking connectivity... done.
16 [root@zhengweiqiang test]# ls
17 yunjisuan
18 [root@zhengweiqiang test]# ls yunjisuan/
19 1  10  2  3  4  5  6  7  8  9  linun.txt

 

 

配置GitLab的SSH密钥连接方式

#git01生成密钥对
[root@zhengweiqiang ~]# ssh-keygen -t rsa -C '804225249@qq.com'
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:EPfg/7kL5kvu5lKrpD1o//ONoWVNvBizwNfWyeIBK9o 804225249@qq.c
omThe key's randomart image is:
+---[RSA 2048]----+
|      . o        |
|       + o       |
|      . . ..     |
|       . o  oo...|
|        S.+.+o=o.|
|        o o+.Xo. |
|       o.E+.O.o  |
|      o+o=+= =   |
|     ...+OO+=..  |
+----[SHA256]-----+

#公钥内容,复制到GitLab上
[root@zhengweiqiang ~]# cd ~/.ssh/
[root@zhengweiqiang .ssh]# cat id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQChdR9x4cbGdm0YMz+3ENiLX96Ol
q2ucoNf63qB4XeC0ilHHj8YboZf5Fs/8MygrVulLG6E5GJnDDx7PcN8hUaF5NfmuiWRb+KK6UJ/olWb+hnathPgvlpuEC7hpF2aCM3tF3Hr55OMxWf0u7Vnj02dHcnYgtoG1/H2OfVqDVL2F4gm45IWB8cPMvuOoECqbgsZOkl2IrQaotlzJUhhRtujCa3ATaE6gQuHztFWqPoXdDCvc1/gzKVPwFHZQvD2PJRDUBl0SRkfUo4EhQcpAYjJS+oU0bwALL++KCXOHPbR8a+2wEEHr2NzxSLfCJ9eGyJRRkwUtSs7wWBzyOMpaFhJ 804225249@qq.com

 

在浏览器打开GitLab

 

 

利用SSH方式克隆GitLab上的一个项目

 1 [root@zhengweiqiang ~]# mkdir -p /test
 2 root@zhengweiqiang ~]# cd /test/
 3 
 4 [root@zhengweiqiang test]# git clone -b linux git@192.168.200.140
 5 :root/yunjisuan.git
 6 Cloning into 'yunjisuan'...
 7 .The authenticity of host '192.168.200.140 (192.168.200.140)' can
 8 't be established.ECDSA key fingerprint is SHA256:Eeo38Y88KcOSuPspyYgLADrIhrx3wRCQQ
 9 fm1/4qHYZY.ECDSA key fingerprint is MD5:93:67:c9:91:71:11:9b:af:80:d0:ed:79:
10 bc:f9:a3:bd.Are you sure you want to continue connecting (yes/no)? yes
11 Warning: Permanently added '192.168.200.140' (ECDSA) to the list 
12 of known hosts.\remote: Enumerating objects: 5, done.
13 remote: Counting objects: 100% (5/5), done.
14 remote: Compressing objects: 100% (4/4), done.
15 remote: Total 5 (delta 1), reused 0 (delta 0)
16 Receiving objects: 100% (5/5), done.
17 Resolving deltas: 100% (1/1), done.
18 Checking connectivity... done.
19 
20 [root@zhengweiqiang test]# ls
21 yunjisuan
22 [root@zhengweiqiang test]# ls yunjisuan/
23 1  10  2  3  4  5  6  7  8  9  linun.txt

 

配置GitLab邮件服务

配置邮件服务的用途:

  • 有和并要求时,邮件通知
  • 账号注册时,邮件验证
  • 修改密码时,通过邮件修改

配置步骤:

  • 开启QQ邮箱的smtp服务
  • 修改GitLab配置
  • 测试邮件服务是否正常

开启GitLab服务postfix服务并开启QQ邮箱的smtp服务

[root@zhengweiqiang ~]# systemctl start postfix
[root@zhengweiqiang ~]# systemctl enable postfix
[root@zhengweiqiang ~]# systemctl status postfi

 

 

 

 

修改配置文件/etc/gitlab/gitlab.rb

 

[root@zhengweiqiang ~]# cat -n /etc/gitlab/gitlab.rb | sed -n '53p;472,480p;618p;'
    53     gitlab_rails['gitlab_email_from'] = 'xxxxxxxxx@qq.com' #GitLab默认邮箱
   472    gitlab_rails['smtp_enable'] = true                     #开启功能
   473    gitlab_rails['smtp_address'] = "smtp.qq.com"      #QQ的smtp服务
   474    gitlab_rails['smtp_port'] = 465                     
   475    gitlab_rails['smtp_user_name'] = "xxxxxxxx@qq.com"  #smtp的邮箱
   476    gitlab_rails['smtp_password'] = "开通QQsmtp的字符串" 
   477    gitlab_rails['smtp_domain'] = "qq.com"                 #smtp域名
   478    gitlab_rails['smtp_authentication'] = "login"
   479    gitlab_rails['smtp_enable_starttls_auto'] = true
   480    gitlab_rails['smtp_tls'] = true
   618    user['git_user_email'] = "xxxxxxxxxx@qq.com"      #git用户邮箱

#重新加载GitLab配置文件
[root@zhengweiqiang ~]# gitlab-ctl reconfigure

#重启服务
[root@zhengweiqiang ~]# gitlab-ctl restart

#进入GitLab控制台进行邮箱发送测试
[root@zhengweiqiang ~]# gitlab-rails console
-----------------------------------------------------------------
-------------------- GitLab:       11.2.3 (06cbee3)
 GitLab Shell: 8.1.1
 postgresql:   9.6.8
-----------------------------------------------------------------
--------------------Loading production environment (Rails 4.2.10)
irb(main):001:0> Notify.test_email('804225249@qq.com','this is ti
irb(main):002:1' tle','hello').deliver_now


特别说明:
Notify.test.email('收件人邮箱''邮件标题','邮件内容')

 

 

 

GitLab的账号注册及分组

账户注册测试

 

 

我们在注册的时候,用的时乱写的邮箱并能注册和登陆

显然这在企业里是绝对不允许的

 

开启GitLab邮箱验证功能

重新登陆管理员账户root,密码666666,进行如下操作

 

退出账号,从新注册后

由上图,我们发现,此时注册用户,已经进不去GitLab了

必须要用户进行邮箱确认后,才可登陆

 

创建一个项目组

 

给组员添加成员并授权

 

 添加权限成功后,GitLab会自动邮件通知这个用户

 

给项目组创建一个新项目

[root@zhengweiqiang ~]# mkdir test
[root@zhengweiqiang ~]# cd test/
[root@zhengweiqiang test]# git init
Initialized empty Git repository in /root/test/.git/
[root@zhengweiqiang test]# 
[root@zhengweiqiang test]# touch {1..5}
[root@zhengweiqiang test]# git add *
[root@zhengweiqiang test]# git commit -m "yun169"

[root@zhengweiqiang test]# git push -u test master
Username for 'http://192.168.200.140:8888': xxxxxxxx@qq.com     
Password for 'http://804225249@qq.com@192.168.200.140:8888': Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 215 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://192.168.200.140:8888/dev/yun169.git
 * [new branch]      master -> master

 

转载于:https://www.cnblogs.com/GokouRuri-zwq/p/10164799.html

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
作为一名高级项目管理师,你需要具备丰富的项目管理经验和技能,能够独立负责复杂项目的规划、实施、监控和总结。以下是一个实际案例,展示了高级项目管理师在项目中的角色和职责。 项目背景: 某知名互联网企业决定推出一款新的社交产品,该产品需要整合多个功能模块,包括消息推送、用户管理、社交圈子、活动组织等,同时需要兼容多个平台,包括PC、iOS、Android等。该项目预计耗时6个月,预算500万人民币。 项目管理团队: 该项目项目经理、技术经理、产品经理、测试经理、市场经理、运营经理等。 项目管理阶段: 1. 项目计划阶段 在项目计划阶段,项目经理需要与其他团队成员一起制定详细的项目计划,包括项目范围、进度、质量、成本和风险等方面。同时,项目经理需要明确项目的目标和具体可衡量的指标,例如活跃用户数、留存率、收入等。 2. 项目实施阶段 在项目实施阶段,项目经理需要协调各个团队成员的工作,确保项目按照计划顺利进行。此时,项目经理需要跟进项目进度、质量和成本等方面,并及时调整计划,确保项目能够按照预期达成目标。 3. 项目监控阶段 在项目监控阶段,项目经理需要密切关注项目进展,识别项目中的问题和风险,并及时采取措施进行调整。此时,项目经理需要与团队成员进行沟通和协调,确保项目在监控阶段顺利完成。 4. 项目总结阶段 在项目总结阶段,项目经理需要对整个项目进行总结,包括项目的成功因素和失败因素,以及项目管理中的经验和教训等。同时,项目经理需要撰写项目报告,对项目的成果和效益进行分析和总结,为公司未来的项目决策提供参考。 以上是一个实际案例,展示了高级项目管理师在项目中的角色和职责。作为一名高级项目管理师,你需要具备丰富的项目管理经验和技能,能够有效地规划、实施、监控和总结复杂项目。在项目管理过程中,你需要与其他团队成员进行沟通和协调,确保项目能够按照预期达成目标。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值