Gitlab 邮件 部署

Gitlab 邮件 部署

基础环境

[root@localhost ~]#systemctl stop firewalld
[root@localhost ~]#systemctl disable firewalld
[root@localhost ~]#setenforce 0
[root@localhost ~]#sed -ri '/SELINUX=/cSELINUX=disabled' /etc/selinux/config
[root@localhost ~]#reboot

安装 依赖

[root@localhost ~]#yum install -y curl openssh-server openssh-clients postfix cronie policycoreutils-python

部署 (yum安装)p添加 yum源

阿里源

[root@qfedu.com ~]# vim /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
Enabled=1
Gpgkey=https://packages.gitlab.com/gpg.key

​ 清华源

[root@qfedu.com ~]# vim gitlab-ce.repo
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
[root@qfedu.com ~]# vim gitlab-ee.repo
[gitlab-ee]
name=Gitlab EE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ee/yum/el$releasever/
gpgcheck=0
enabled=1

官方源

[root@qfedu.com ~]# vim runner_gitlab-ci-multi-runner.repo
[runner_gitlab-ci-multi-runner]
name=runner_gitlab-ci-multi-runner
baseurl=https://packages.gitlab.com/runner/gitlab-ci-multi-runner/el/7/$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/runner/gitlab-ci-multi-runner/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

[runner_gitlab-ci-multi-runner-source]
name=runner_gitlab-ci-multi-runner-source
baseurl=https://packages.gitlab.com/runner/gitlab-ci-multi-runner/el/7/SRPMS
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/runner/gitlab-ci-multi-runner/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

脚本

[root@qfedu.com ~]# curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash

安装

[root@localhost ~]# yum -y install gitlab-ce

手动

https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7/

rpm 直接 rpm -ivh 包名 即可

Git 配置登陆链接

[root@localhsot ~]# vim /etc/gitlab/gitlab.rb
# 设置监听的地址
***
external_url 'http://192.168.152.142'
***

初始化 gitlab

[root@localhost ~]# gitlab-ctl reconfigure

启动

[root@localhost ~]#gitlab-ctl start

HTTPS方式

[root@root@localhost ~]# vim /etc/gitlab/gitlab.rb
letsencrypt['enable'] = true 
# 这应该是一组要添加为联系人的电子邮件地址
letsencrypt['contact_emails'] = ['[email protected]']  

Gitlab 添加 smtp 邮件功能

[root@localhsot ~]# vim /etc/gitlab/gitlab.rb
### Email Settings
gitlab_rails['gitlab_email_enabled'] = true  
# 输入你的邮箱
gitlab_rails['gitlab_email_from'] = '你的邮箱'  
gitlab_rails['gitlab_email_display_name'] = '主题'  
gitlab_rails['gitlab_email_reply_to'] = '默认发送的邮箱'  
gitlab_rails['gitlab_email_subject_suffix'] = '内容'  
### Gitlab email server settings 
###! Docs: https://docs.gitlab.com/omnibus/settings/smtp.html 
###! **Use smtp instead of sendmail/postfix.**
gitlab_rails['smtp_enable'] = true  
gitlab_rails['smtp_address'] = "smtp.域名"  
gitlab_rails['smtp_port'] = 465  
gitlab_rails['smtp_user_name'] = "想要绑定的邮箱"  
gitlab_rails['smtp_password'] = "该邮箱的smtp 授权码" 
gitlab_rails['smtp_domain'] = "域名"  
gitlab_rails['smtp_authentication'] = "login"  
gitlab_rails['smtp_enable_starttls_auto'] = true  
gitlab_rails['smtp_tls'] = true

每次更改配置文件 都需要 初始化、

[git@localhost ~]# gitlab-ctl reconfigure

Gitlab 发送邮件测试

[root@loalhost ~]# gitlab-rails console    # 时间长一点
Loading production environment (Rails 4.2.10)
irb(main):001:0>  Notify.test_email('发送到哪个邮箱', '主题', '内容').deliver_now

t ~]# gitlab-rails console # 时间长一点
Loading production environment (Rails 4.2.10)
irb(main):001:0> Notify.test_email(‘发送到哪个邮箱’, ‘主题’, ‘内容’).deliver_now


你可能感兴趣的:(git)