Centos7安裝配置gitlab

Centos7安裝配置gitlab

這篇文字我會介紹在Centos7上安裝gitlab,配置gitlab的smtp,而且建立項目demo。
sudo yum install openssh-server

sudo yum install postfix

sudo yum install cronie

sudo service postfix start

sudo chkconfig postfix on

sudo lokkit -s http -s ssh

使用清華大學gitlab的鏡像https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/

curl https://packages.gitlab.com/gpg.key 2> /dev/null | sudo apt-key add - &>/dev/null
vi /etc/yum.repos.d/gitlab-ce.repo

 

[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key
而後
sudo yum makecache
sudo yum install gitlab-ce 

而後打開,將修改成本身的IP地址或者本身的域名,而後編譯,這裏會用chef來進行,/etc/gitlab/gitlab.rbexternal_url = 'http://git.example.com'

這樣若是沒有報錯就是安裝完成了

直接在瀏覽器訪問剛纔修改的本身的ip或者域名,就能看到gitlab的頁面了,登錄用下面的用戶名和密碼。sudo gitlab-ctl reconfigure
Username: root 
Password: 5iveL!fe

登錄後會要求你更改密碼的。git

 

接下來進行配置

配置smtp
$ sudo vi /etc/gitlab/gitlab.rb                            
# Change the external_url to the address your users will type in their browser
external_url 'http://xxhost.com'

#Sending application email via SMTP
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 25 
gitlab_rails['smtp_user_name'] = "xxuser@163.com"
gitlab_rails['smtp_password'] = "xxpassword"
gitlab_rails['smtp_domain'] = "163.com"
gitlab_rails['smtp_authentication'] = :login
gitlab_rails['smtp_enable_starttls_auto'] = true

##修改gitlab配置的發信人
gitlab_rails['gitlab_email_from'] = "xxuser@163.com"
user["git_user_email"] = "xxuser@163.com"

 注意163,qq什麼的記得加白名單,否則可能當成垃圾郵件了。。。vim

而後再編譯下segmentfault

sudo gitlab-ctl reconfigurecentos

 

登錄去修改下本身的郵箱,在profile裏面瀏覽器

 

建立一個新的group,命名爲devopsbash

在這個組裏建立一個新的project,命名爲openstackapp

成功後會在頂部提示你添加ssh密鑰,點開後提示你怎麼建立dom

在主機上
# ssh-keygen -C user@XX.com

而後空格繼續,最後會在~/.ssh/下看到公鑰,複製到頁面中那裏就行。ssh

 

而後註冊一個新的用戶wenbin,這裏會要你輸入郵箱驗證,這裏能夠看到郵箱會收到以前設置smtp中郵件發送的郵件,激活就行。curl

而後去主機生成一個新的用戶,生成ssh的key。

 

用root登錄dashboard,而後把wenbin用戶添加到devops這個組中,權限爲reporter

而後用wenbin登錄,能夠看到了openstack的project,而後添加sshkey,這樣就能夠pull這個項目了。

 

安裝git:    sudo yum install git,

而後就能夠克隆代碼了:

git clone git@gitlab.wenbin.com:devops/openstack.git

會提示你克隆了一個空目錄

[wenbin@gitlab ~]$ git clone git@gitlab.wenbin.com:devops/openstack.git
Cloning into 'openstack'...
warning: You appear to have cloned an empty repository.

[wenbin@gitlab ~]$ cd openstack/
[wenbin@gitlab openstack]$ ll
total 0
[wenbin@gitlab openstack]$ git config user.name wenbin
[wenbin@gitlab openstack]$ git config user.email lxxx@163.com
[wenbin@gitlab openstack]$ vim test.txt
[wenbin@gitlab openstack]$ ll
total 4
-rw-rw-r--. 1 wenbin wenbin 5 Mar 30 23:47 test.txt
[wenbin@gitlab openstack]$ git add .
[wenbin@gitlab openstack]$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#	new file:   test.txt
#
[wenbin@gitlab openstack]$ git commit -m 'for test'
[master (root-commit) 42eb67c] for test
 1 file changed, 1 insertion(+)
 create mode 100644 test.txt
[wenbin@gitlab openstack]$ git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

GitLab: You are not allowed to push code to this project.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

能夠看到提示push失敗,由於wenbin只是reporter

當權限改成developer後,再次執行

git push -u origin master
就發現能夠成功的push了



到此爲止,centos7安裝gitlab,配置smtp,創建用戶和項目,clone代碼和push已經ok,期待後面的gerrit和jenkins的整合吧。


參考資料:

http://blog.csdn.net/williamwanglei/article/details/38498465
https://about.gitlab.com/downloads/#centos7
https://segmentfault.com/a/1190000002722631
相關文章
相關標籤/搜索