安裝Gitlab
Step 1.安準基礎依賴
$ yum install -y curl policycoreutils-python openssh-server
Step 2.安裝Postfix
說明:Postfix是一個郵件伺服器,GitLab發送郵件需要用到
$ yum install -y postfix
啟動postfix并設定為開機啟動
$ systemctl enable postfix
$ systemctl start postfix
Step 3.部署GitLab過程
1.添加GitLab社群版Package
$ curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
2.安裝GitLab社群版
$ yum install -y gitlab-ce
3.安裝成功後會看到gitlab-ce列印了以下圖形
Step 4.配置GitLab站點Url
說明:GitLab預設的配置檔案路徑是/etc/gitlab/gitlab.rb
預設的站點Url配置項是:
external_url 'http://gitlab.example.com'
這裡我将GitLab站點Url修改為http://192.168.82.144
也可以用IP代替域名,這裡根據自己需求來即可
#修改配置檔案
$ vim /etc/gitlab/gitlab.rb
#配置首頁位址(大約在第15行)
external_url 'http://192.168.82.144'
Step 5.啟動并通路GitLab
1.啟動
$ gitlab-ctl reconfigure
完成後将會看到如下輸出
Running handlers:
Running handlers complete
Chef Client finished, 513/1343 resources updated in 04 minutes 39 seconds
gitlab Reconfigured!
2.通路GitLab
這時候會提示為管理者賬号設定密碼。管理者賬号預設username是root。
設定完成之後即可使用root賬号登入,登陸後會進入歡迎界面。
Step 6.GitLab常用配置
1、禁用建立組權限
GitLab預設所有的注冊使用者都可以建立組。但對于團隊來說,通常隻會給Leader相關權限。
雖然可以在使用者管理界面取消權限,但畢竟不友善。我們可以通過配置GitLab預設禁用建立組權限。
修改配置檔案
$ vim /etc/gitlab/gitlab.rb
#開啟gitlab_rails['gitlab_default_can_create_group'] 選項,并将值設定為false
### GitLab user privileges
gitlab_rails['gitlab_default_can_create_group'] = false
儲存後,重新配置并啟動GitLab
$ gitlab-ctl reconfigure
Step 7.建立群組
說明:群組主要的目的是聚合一群使用者和它們維護的項目,隻要在如下的界面中添加群組相關資訊最後點選建立就可以
Step 8.建立使用者
建立完群組後就需要建立使用者賬号,通常在企業裡都是員工向管理源請求加入某個群組,管理者會根據員工提供的個人系資訊直接建立賬号,并且将賬号添加到對應的群組中
Step 9.建立項目
說明:項目的建立也很簡單可以在之前建立的群組裡添加項目,這樣整個項目就歸所在群組維護,可以為項目增加各種維護人員,需要注意的是項目裡的master分支等特殊分支developer使用者無法更新,隻有master使用者才有權限更新
Step 10.權限設定--群組
1.打開設定,點已建立的群組
2.将需要添加到這個群組的使用者選中
3.選擇權限(身份)
$ vim /etc/gitlab/gitlab.rb
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "[email protected]"
gitlab_rails['smtp_password'] = "password"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['gitlab_email_from'] = '[email protected]'
修改後重新開機
gitlab-ctl restart