搭建gitlab
搭建Gitlab
一、 概述
持续集成交付,是自动化的重要一环,本文主要介绍代码更新后自动构建、发布上线。
1、 安装gitlab
下载地址:
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
选择自己需要的版本。
# rpm -ivh gitlab-ce-8.13.8-ce.0.el7.x86_64.rpm
#vim /ect/gitlab/gitlab.rb
external_url 'http://192.168.8.209'
unicorn['listen'] = '0.0.0.0'
unicorn['port'] = 8082 #默认是8080,不要与本机的重复。
gitlab_shell['auth_file'] = "/var/opt/gitlab/.ssh/authorized_keys"
修改nginx端口:
# vim /var/opt/gitlab/nginx/conf/gitlab-http.conf
server {
listen *:81;
server_name 192.168.96.6;
默认用户名:root 密码:5iveL!fe
#gitlab-ctl reconfigure
#gitlab-ctl status #正常状态如下。
run: gitlab-workhorse: (pid 180556) 20441s; run: log: (pid 178968) 20799s
run: logrotate: (pid 23601) 2794s; run: log: (pid 179092) 20795s
run: nginx: (pid 180568) 20440s; run: log: (pid 179016) 20797s
run: postgresql: (pid 178651) 20843s; run: log: (pid 178650) 20843s
run: redis: (pid 178530) 20849s; run: log: (pid 178529) 20849s
run: sidekiq: (pid 180548) 20441s; run: log: (pid 178918) 20805s
run: unicorn: (pid 180526) 20444s; run: log: (pid 178863) 20807s
2、sendmail邮件配置
vi /etc/gitlab/gitlab.rb 主要修改内容:
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.163.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "youremail@163.com"
gitlab_rails['smtp_password'] = "客户端秘钥"这个密码是在网易邮箱开通smtp是手机收到的一段用于客户端的密码。
gitlab_rails['smtp_domain'] = "163.com"
gitlab_rails['smtp_authentication'] = :login
gitlab_rails['smtp_enable_starttls_auto'] = true
##修改gitlab配置的发信人
gitlab_rails['gitlab_email_from'] = "youremai@163.com"
user["git_user_email"] = "youremai@163.com"
保存退出后
生效方法:gitlab-ctl reconfigure
也可以用QQ:
QQ邮箱方式(我没用这个):
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = "发送邮件的帐号"
gitlab_rails['smtp_password'] = "发送邮件帐号的密码"
gitlab_rails['smtp_domain'] = "smtp.qq.com"
gitlab_rails['smtp_authentication'] = :plain
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['gitlab_email_from'] = "与发送邮件的帐号相同"
user["git_user_email"] = "与发送邮件的帐号相同"
http://tt4it.com/exchange/blog/discuss/76/
这里,端口使用的是25,不是腾讯企业邮箱官方说的465,请注意。
3、忘记密码
#首先在数据库里面查到,要修改用户的id:
#postgres psql gitlabhq_production
>select * from users;
# gitlab-rails console production
>user = User.where(id:1).first
>user.password='mytest'
>user.save!
修改成功会反回true。