gitlab版本控制
阿新 • • 發佈:2018-09-04
eve options ble 版本 onf man ssh pri 修改 gitlab版本控制
[TOC]
1.版本控制介紹
定義
版本控制是指對軟件開發過程中各種代碼程序、配置文件及說明文檔等文件變更的管理,是軟件配置管理的核心思想之一。
功能
- 追蹤文件的變更
- 並行開發
常用的版本控制工具:
- gitlab
- suversion
2.gitlab部署
關閉防火墻以及SELINUX
[root@linfan ~]# systemctl stop firewalld [root@linfan ~]# systemctl disable firewalld [root@linfan ~]# sed -ri ‘s/^(SELINUX=).*/\1disabled/g‘ /etc/selinux/config [root@linfan ~]# setenforce 0
配置yum源
[root@linfan ~]# cd /etc/yum.repos.d/ [root@linfan yum.repos.d]# curl -o 163.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 1572 100 1572 0 0 279 0 0:00:05 0:00:05 --:--:-- 382 [root@linfan yum.repos.d]# sed -i ‘s/\$releasever/7/g‘ /etc/yum.repos.d/163.repo [root@linfan yum.repos.d]# sed -i ‘s/^enabled=.*/enabled=1/g‘ 163.repo [root@linfan yum.repos.d]# yum -y install epel-release
安裝git
[root@linfan ~]# yum -y install git
安裝依賴包
[root@linfan ~]# yum -y install curl openssh-server openssh-clients postfix cronie policycoreutils-python
啟動postfix服務並設置開機自啟動
[root@linfan ~]# systemctl restart postfix
[root@linfan ~]# systemctl enable postfix
下載gitlab的rmp包
[root@linfan ~]# cd /usr/src [root@linfan src]# ls debug kernels [root@linfan src]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/y --2018-09-04 02:35:08-- https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/y Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... um/el7/gitlab-ce-11.2.1-ce.0.el7.x86_64.rpm101.6.8.193, 2402:f000:1:408:8100::1 Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... connected. HTTP request sent, awaiting response... 404 Not Found 2018-09-04 02:35:09 ERROR 404: Not Found. [root@linfan src]# um/el7/gitlab-ce-11.2.1-ce.0.el7.x86_64.rpm -bash: um/el7/gitlab-ce-11.2.1-ce.0.el7.x86_64.rpm: No such file or directory [root@linfan src]# cd [root@linfan ~]# cd /usr/src [root@linfan src]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.2.1-ce.0.el7.x86_64.rpm --2018-09-04 02:35:59-- https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.2.1-ce.0.el7.x86_64.rpm Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1 Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 444944490 (424M) [application/x-redhat-package-manager] Saving to: ‘gitlab-ce-11.2.1-ce.0.el7.x86_64.rpm’ 100%[================================================================================>] 444,944,490 5.76MB/s in 71s 2018-09-04 02:37:10 (5.96 MB/s) - ‘gitlab-ce-11.2.1-ce.0.el7.x86_64.rpm’ saved [444944490/444944490] [root@linfan src]# ls debug gitlab-ce-11.2.1-ce.0.el7.x86_64.rpm kernels
安裝gitlab
[root@linfan src]# rpm -ivh gitlab-ce-11.2.1-ce.0.el7.x86_64.rpm
warning: gitlab-ce-11.2.1-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:gitlab-ce-11.2.1-ce.0.el7 ################################# [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.
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
修改配置文件
[root@linfan ~]# vim /etc/gitlab/gitlab.rb
...
...
## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
external_url ‘http://192.168.24.130‘ 修改此處為自己的IP或域名
## Roles for multi-instance GitLab
##! The default is to have no roles enabled, which results in GitLab running as an all-in-one instance.
##! Options:
##! redis_sentinel_role redis_master_role redis_slave_role geo_primary_role geo_secondary_role
##! For more deatils on each role, see:
##! https://docs.gitlab.com/omnibus/roles/README.html#roles
##!
# roles [‘redis_sentinel_role‘, ‘redis_master_role‘]
...
...
重新加載配置文件並重啟gitlab
[root@linfan ~]# gitlab-ctl reconfigure
[root@linfan ~]# gitlab-ctl restart
查看當前gitlab版本
[root@linfan ~]# head -1 /opt/gitlab/version-manifest.txt
gitlab-ce 11.2.1
設置管理員密碼
[root@linfan ~]# gitlab-rails console production
-------------------------------------------------------------------------------------
GitLab: 11.2.1 (2d6c1c6)
GitLab Shell: 8.1.1
postgresql: 9.6.8
-------------------------------------------------------------------------------------
Loading production environment (Rails 4.2.10)
irb(main):001:0> user = User.where(id: 1).first //id為1是超級管理員
=> #<User id:1 @root>
irb(main):002:0> user.password = ‘linfan123‘//密碼至少8個字符
=> "linfan123"
irb(main):003:0> user.save! //保存修改,無問題則返回true
Enqueued ActionMailer::DeliveryJob (Job ID: feb0d3ec-534f-4e87-9dad-ceafbae40a53) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", gid://gitlab/User/1
=> true
irb(main):004:0> exit //退出
gitlab管理
在瀏覽器輸入IP或域名地址
進去後創建groups users projects 選擇Settings下的Members添加項目的成員或組
gitlab常用管理操作
- 項目管理(通常只是創建新項目)
- 創建成員組(真對某個項目創建一個成員組)
-
用戶管理(此用戶是gitlab用戶而非系統用戶)
- 來了新員工 為其添加gitlab用戶
- 員工離職,將其gitlab用戶禁用或刪除
gitlab版本控制