您的位置:首页 > 运维架构 > Linux

Centos7安装配置gitlab

2016-04-09 19:08 585 查看
Centos7安装配置gitlab

这篇文字我会介绍在Centos7上安装gitlab,配置gitlab的smtp,并且创建项目demo。
sudoyuminstallopenssh-server sudoyuminstallpostfix sudoyuminstallcronie sudoservicepostfixstart sudochkconfigpostfixon sudolokkit-shttp-sssh使用清华大学gitlab的镜像https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/curlhttps://packages.gitlab.com/gpg.key2>/dev/null|sudoapt-keyadd-&>/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
然后
sudoyummakecache sudoyuminstallgitlab-ce
然后打开[code]/etc/gitlab/gitlab.rb
,将
external_url='http://git.example.com'
修改为自己的IP地址或者自己的域名,然后编译,这里会用chef来进行,[/code]
sudogitlab-ctlreconfigure

这样如果没有报错就是安装完成了直接在浏览器访问刚才修改的自己的ip或者域名,就能看到gitlab的页面了,登陆用下面的用户名和密码。[/code]
Username:root
Password:5iveL!fe
登陆后会要求你更改密码的。
接下来进行配置

配置smtp
$sudovi/etc/gitlab/gitlab.rb
#Changetheexternal_urltotheaddressyouruserswilltypeintheirbrowser
external_url'http://xxhost.com'

#SendingapplicationemailviaSMTP
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什么的记得加白名单,不然可能当成垃圾邮件了。。。然后再编译下sudogitlab-ctlreconfigure登陆去修改下自己的邮箱,在profile里面创建一个新的group,命名为devops在这个组里创建一个新的project,命名为openstack成功后会在顶部提示你添加ssh密钥,点开后提示你怎么创建在主机上 #ssh-keygen-Cuser@XX.com然后空格继续,最后会在~/.ssh/下看到公钥,复制到页面中那里就行。然后注册一个新的用户wenbin,这里会要你输入邮箱验证,这里可以看到邮箱会收到之前设置smtp中邮件发送的邮件,激活就行。然后去主机生成一个新的用户,生成ssh的key。用root登陆dashboard,然后把wenbin用户添加到devops这个组中,权限为reporter然后用wenbin登陆,可以看到了openstack的project,然后添加sshkey,这样就可以pull这个项目了。安装git:sudoyuminstallgit,然后就可以克隆代码了:gitclonegit@gitlab.wenbin.com:devops/openstack.git会提示你克隆了一个空目录[wenbin@gitlab~]$gitclonegit@gitlab.wenbin.com:devops/openstack.git Cloninginto'openstack'... warning:Youappeartohaveclonedanemptyrepository. [wenbin@gitlab~]$cdopenstack/ [wenbin@gitlabopenstack]$ll total0 [wenbin@gitlabopenstack]$gitconfiguser.namewenbin [wenbin@gitlabopenstack]$gitconfiguser.emaillxxx@163.com [wenbin@gitlabopenstack]$vimtest.txt [wenbin@gitlabopenstack]$ll total4 -rw-rw-r--.1wenbinwenbin5Mar3023:47test.txt [wenbin@gitlabopenstack]$gitadd. [wenbin@gitlabopenstack]$gitstatus #Onbranchmaster # #Initialcommit # #Changestobecommitted: #(use"gitrm--cached<file>..."tounstage) # # newfile:test.txt # [wenbin@gitlabopenstack]$gitcommit-m'fortest' [master(root-commit)42eb67c]fortest 1filechanged,1insertion(+) createmode100644test.txt [wenbin@gitlabopenstack]$gitpush warning:push.defaultisunset;itsimplicitvalueischangingin Git2.0from'matching'to'simple'.Tosquelchthismessage andmaintainthecurrentbehaviorafterthedefaultchanges,use: gitconfig--globalpush.defaultmatching Tosquelchthismessageandadoptthenewbehaviornow,use: gitconfig--globalpush.defaultsimple See'githelpconfig'andsearchfor'push.default'forfurtherinformation. (the'simple'modewasintroducedinGit1.7.11.Usethesimilarmode 'current'insteadof'simple'ifyousometimesuseolderversionsofGit) GitLab:Youarenotallowedtopushcodetothisproject. fatal:Couldnotreadfromremoterepository. Pleasemakesureyouhavethecorrectaccessrights andtherepositoryexists.可以看到提示push失败,因为wenbin只是reporter当权限改为developer后,再次执行
gitpush-uoriginmaster
就发现可以成功的push了

到此为止,centos7安装gitlab,配置smtp,建立用户和项目,clone代码和push已经ok,期待后面的gerrit和jenkins的整合吧。

参考资料:
http://blog.csdn.net/williamwanglei/article/details/38498465https://about.gitlab.com/downloads/#centos7https://segmentfault.com/a/1190000002722631



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: