我们想要搭建自己的私有仓库,更加快捷的来获得自己的项目和同步项目,我们该怎么做呢,这里我们可以自己搭建私有仓库,就需要使用gitlab

一、gitlab

环境:
          git:rhel7,用来搭建gitlab,建议多点内存,2g起步,gitlab比较吃内存

          jenkins:rhrl7,用来搭建jenkins

         软件:github,jenkins ==> 点击下载   提取码: wyxb

1.安装gitlab

[root@git gitlab]# yum install gitlab-ce-11.2.0-ce.0.el7.x86_64.rpm -y

2.设置gitlab

[root@git gitlab]# vim /etc/gitlab/gitlab.rb 
external_url 'http://172.25.1.1'
[root@git gitlab]# gitlab-ctl  reconfigure            ##重新配置gitlab

3.访问gitlab

我们再浏览器输入172.25.1.1,就可以访问到gitlab,第一次需要设置密码

设置完密码之后就可以登陆了

我们可以查看gitlab的状态

[root@git gitlab]# gitlab-ctl status
run: alertmanager: (pid 3829) 962s; run: log: (pid 3839) 962s
run: gitaly: (pid 3783) 964s; run: log: (pid 3793) 964s
run: gitlab-monitor: (pid 3802) 964s; run: log: (pid 3805) 963s
run: gitlab-workhorse: (pid 3767) 965s; run: log: (pid 3775) 964s
run: logrotate: (pid 3380) 1031s; run: log: (pid 3803) 963s
run: nginx: (pid 3357) 1037s; run: log: (pid 3776) 964s
run: node-exporter: (pid 3454) 1019s; run: log: (pid 3794) 964s
run: postgres-exporter: (pid 3846) 962s; run: log: (pid 3852) 962s
run: postgresql: (pid 3089) 1132s; run: log: (pid 3760) 965s
run: prometheus: (pid 3814) 963s; run: log: (pid 3818) 963s
run: redis: (pid 3029) 1143s; run: log: (pid 3759) 965s
run: redis-exporter: (pid 3562) 1007s; run: log: (pid 3808) 963s
run: sidekiq: (pid 3333) 1044s; run: log: (pid 3761) 965s
run: unicorn: (pid 3295) 1050s; run: log: (pid 3762) 965s

4.建立私有仓库

首先新建私有仓库

然后点击头象菜单中的setting

添加ssh-key

ssh-key下面的方式查看

[root@git gitlab]# cat ~/.ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQQi9pxhnrlC0GdtCP2hgd83azEI91kSaq1e5+29OM3jRB3hZpqyFeDIZQgfsu6xXCWRriwH9jXGlXR8P6jfc8Fm6ZBlT68EmVRxggSvZiMBxsHv6NTYekf7/VftlGIOAooKQfqkmTBy6rmrVgFN04QQDpAe77zzjfDiloF4TZXiybYUFjPTAXLj/IEW8gQlUupk7hWhjAtNHcua/qNmJNgiUFpTJUAow6/ynrep3as6LKq7fzW3uXLNj77jaQl4ddPZcyblmuRGibTs0np9pIDT4vilvV+4Sk9iyCEYkHDyKn2nnSwD/sRkZBjdcHNN/QaJtQF1wxZlzRsiX8GdrT root@git

添加成功截图

我们在gitlab的新建的项目里面新添加一个文件,然后通过克隆的方式下载到本地

[root@git ~]# git clone git@172.25.1.1:root/nelws.git
Cloning into 'nelws'...
The authenticity of host '172.25.1.1 (172.25.1.1)' can't be established.
ECDSA key fingerprint is 1d:2b:c0:f8:95:e1:0c:bd:5c:f7:f4:62:af:3e:8a:6f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.25.1.1' (ECDSA) to the list of known hosts.
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
[root@git ~]# cd nelws/
[root@git nelws]# ls
README.md
[root@git nelws]# touch test
[root@git nelws]# echo test > test
[root@git nelws]# git add test
[root@git nelws]# git commit -m "add test"
[master 35ac67f] add test
 1 file changed, 1 insertion(+)
 create mode 100644 test
[root@git nelws]# git push -u origin master
Counting objects: 4, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 271 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@172.25.1.1:root/nelws.git
   599e458..35ac67f  master -> master
Branch master set up to track remote branch master from origin.

接下来,我们在gitlab端查看

ok~

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐