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
相关文章
相关标签/搜索