服务器安装
docker run --detach \
--hostname gitlab.example.com \
--publish 4443:443 --publish 8888:8888 --publish 2222:22 \
--name gitlab \
--restart always \
--volume /usr/local/docker_gitlab/config:/etc/gitlab \
--volume /usr/local/docker_gitlab/logs:/var/log/gitlab \
--volume /usr/local/docker_gitlab/data:/var/opt/gitlab \
--volume /usr/local/docker_gitlab/backup:/usr/local/backup \
--shm-size 256m \
gitlab/gitlab-ce:latest
修改external_url
vim /etc/gitlab/gitlab.rb #修改external_url
external_url='http://192.168.0.60:8888' #可以加端口
nginx['listen_port'] = 8888
gitlab-ctl reconfigure
gitlab-ctl restart
netstat -t|grep 8888
默认root密码cat /etc/gitlab/initial_root_password
url:http://192.168.0.60:8888/
配置邮件服务及用户组注册
配置邮箱服务的用途
有合并请求时,邮件通知
账号注册时,邮件验证
修改密码时,通过邮件修改
配置步骤:
1.开后邮箱(如QQ邮箱)的smtp服务
不建议使用163邮箱,发几次之后,就不能再次发送了
2.修改gitlab配置
vim /etc/gitlab/gitlab.rb
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.qq.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "631646620@qq.com"
gitlab_rails['smtp_password'] = "bcxnkwialikobbhc"
gitlab_rails['smtp_domain'] = "qq.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true
gitlab_rails['smtp_pool'] = true
user['git_user_name'] = "GitLab"
user['git_user_email'] = "631646620@qq.com"
gitlab_rails['gitlab_email_from'] = '631656885@qq.com'
#gitlab-ctl reconfigure
测试邮件服务是否正常
#gitlab-rails console
>Notify.test_email('接收方邮件地址@qq.com','邮件标题title','邮件内容zheng wen').deliver_now
>Notify.test_email('lejianyuan@otoyix.com','titletest','邮件内容zheng wen').deliver_now
#####gitlab帐号注册及分组
Admin Area -> Settings -> Sign-up restrictons ->Expand
Sign-up enable#勾选
Send confirmation email on sign-up #勾选,发送邮箱进行验证,防止假邮箱地址注册
#创建组
Groups -> New Group (选择Private,即组成员可见)
组成员权限(guest、reporter、developer、master、owner)一般选择master......
如此就可以在组中创建工程,如果设置为组中成员可见的权限,那么不在组中的成员,就不能访问此组中的内容
gitlab分支和标签的保护
为了保护特定的分支不被随意的合并,以免影响相应的分支
分支保护
进入仓库 -> settings -> Repository -> Protected Branch ->expand
branch: master
Allowed to merge : Masters #master权限成员可以合并分支
Allowed to push : Masters #push权限,有push权限,就会有merge权限
标签保护
进入仓库 -> settings -> Repository -> Protected tags ->expand
Tag:
Allowed to create:
自动化勾子
jenkins
构建触发器 -> Build when a change is pushed to GitLab. GitLab webhook URL: http://192.168.0.122:64088/project/test2
高级 -token -> Generate生成一个token
gitlab
1、Admin Area - settings -> outbound requests ->expand
勾选(Allow requests to the local network from hooks and services)
新版gitlab
Admin Area - settings ->network -> outbound requests ->expand
2、进入项目 ->settings -> Integrations : 输入:
url :jenkins(GitLab webhook URL): http://192.168.0.122:64088/project/test2
token:
pushed
点击 add webhook
----------- end