设为首页 收藏本站
查看: 774|回复: 0

[经验分享] gitlab配置邮件通知功能操作记录

[复制链接]

尚未签到

发表于 2018-1-10 14:07:30 | 显示全部楼层 |阅读模式
  之前已经介绍了gitlab的部署http://www.cnblogs.com/kevingrace/p/5651402.html
  但是没有配置邮箱通知功能,今天这里介绍下gitlab安装后的邮箱配置操作:
  注意几点:
  1)登陆gitlab后,只能在admin管理员账号下创建新账号,一般来说,创建好新账号后,会自动给新账号预留的邮箱发送通知邮件,点击邮件中的链接进行激活,首次登陆gitlab会进行密码设置。
  2)如果不想在通知邮件里修改密码或没收到邮件,也可以绕过这一步。即在新账号创建后,在管理员状态下“编辑”新账号,设置一个密码,这个是初始密码。然后登陆新账号,这时候登陆后会强制进行初始密码的修改。
  邮箱通知功能开通后,除了上面可以发送新建账号的激活邮件,还可以让用户通过邮箱注册gitlab,然后在管理员账号下对新注册账号进行project和group等权限授予。
  这个有点不太安全,后续会介绍gitlab+openldap对接的操作记录,跟openldap结合后,gitlab的登陆就只能是LDAP方式了,邮箱注册功能就会失效!
  废话不多说了,下面是gitlab开通邮箱通知功能的操作记录:
  这里测试使用的是阿里云的企业邮箱
  假设通知邮件的邮箱名为ops@wangshibo.cn,密码为zh@123bj
  主要修改gitlan的三个文件,邮箱相关设置如下:
  1)编辑/opt/gitlab-8.8.4-0/apps/gitlab/htdocs/config/gitlab.yml文件,开通email邮件功能
[iyunv@test-huanqiu ~]# vim /opt/gitlab-8.8.4-0/apps/gitlab/htdocs/config/gitlab.yml

  .........
  email_enabled: true
  # Email address used in the "From" field in mails sent by GitLab
  email_from: ops@wangshibo.cn
  #email_display_name: GitLab
  #email_reply_to: noreply@example.com
  ........
  2)编辑/opt/gitlab-8.8.4-0/apps/gitlab/htdocs/config/initializers/smtp_settings.rb.sample文件
[iyunv@test-huanqiu ~]# vim /opt/gitlab-8.8.4-0/apps/gitlab/htdocs/config/initializers/smtp_settings.rb.sample

  ........
  ActionMailer::Base.smtp_settings = {
  address: "smtp.wangshibo.cn",
  port: 25,
  user_name: "ops@wangshibo.cn",
  password: "zh@123bj",
  domain: "wangshibo.cn",
  authentication: :login,
  enable_starttls_auto: true,
  openssl_verify_mode: 'none' # See ActionMailer documentation for other possible options
  }
  .......
  3)编辑/opt/gitlab-8.8.4-0/apps/gitlab/htdocs/config/environments/production.rb文件,添加下面标红的几行内容,设置smtp模式
[iyunv@test-huanqiu ~]# vim /opt/gitlab-8.8.4-0/apps/gitlab/htdocs/config/environments/production.rb

  .......
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
  :address => "smtp.wangshibo.cn",
  :port => "25",
  :domain => "wangshibo.cn",
  :authentication => :plain,
  :user_name => "ops@wangshibo.cn",
  :password => "zh@123bj",
  :enable_starttls_auto => true
  }
  config.eager_load = true
  config.allow_concurrency = false
  .......
  最后,重启gitlab相关服务
[iyunv@localhost gitlab-8.8.4-0]# pwd

  /opt/gitlab-8.8.4-0
[iyunv@localhost gitlab-8.8.4-0]# ./ctlscript.sh restart

  ------------------------------------------------------------------------
  下面是腾讯企业邮箱的一个配置:
  假设腾讯企业邮箱是:noreply@wangshibo.com,密码是H8*Cy9wXn8$SuhbT
  1)gitlab.yml文件配置
  ......
  email_enabled: true
  # Email address used in the "From" field in mails sent by GitLab
  email_from: noreply@wangshibo.com
  #email_display_name: GitLab
  #email_reply_to: noreply@wangshibo.com
  ......
  2)smtp_settings.rb 文件配置
  .....
  ActionMailer::Base.smtp_settings = {
  address: "smtp.exmail.qq.com",
  port: 25,
  user_name: "noreply@wangshibo.com",
  password: "H8*Cy9wXn8$SuhbT",
  domain: "smtp.qq.com",
  authentication: :plain,
  enable_starttls_auto: true,
  openssl_verify_mode: 'none' # See ActionMailer documentation for other possible options
  }
  3)production.rb文件配置
  ......
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
  :address => "smtp.exmail.qq.com",
  :port => "25",
  :domain => "smtp.qq.com",
  :authentication => :plain,
  :user_name => "noreply@wangshibo.com",
  :password => "H8*Cy9wXn8$SuhbT",
  :enable_starttls_auto => true
  }
  config.eager_load = true
  config.allow_concurrency = false

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-433565-1-1.html 上篇帖子: GitLab 安装配置笔记(转) 下篇帖子: CentOS7下gitlab的搭建
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表