zoukankan      html  css  js  c++  java
  • 版本管理之gitlab实践教程:基础篇

    这篇文章主要介绍一下gitlab中如何进行邮件的配置,并使用163邮箱进行验证。

    设定文件

    可以通过直接设定环境变量或者修正gitlab.rb的方式来设定,本文使用直接设定gitlab.rb文件方式。

    设定文件所在目录
    gitlab.rb /etc/gitlab

    修改内容

    修改如下内容(对应的xx相关内容使用自己的邮箱地址,注意邮箱此处需要一致)

    gitlab_rails['gitlab_email_from'] = 'xxxxxxxx@163.com'
    gitlab_rails['smtp_enable'] = true
    gitlab_rails['smtp_address'] = "smtp.163.com"
    gitlab_rails['smtp_port'] = 25
    gitlab_rails['smtp_user_name'] = "xxxxxxxx@163.com"
    gitlab_rails['smtp_password'] = "xxxxxx"
    gitlab_rails['smtp_domain'] = "163.com"
    gitlab_rails['smtp_authentication'] = "login"
    gitlab_rails['smtp_enable_starttls_auto'] = false
    gitlab_rails['smtp_openssl_verify_mode'] = 'peer' 
    user['git_user_email'] = "xxxxxxxx@163.com"
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    修改起效

    修改了gitlab.rb文件,可以使用如下命令使其生效。

    gitlab-ctl reconfigure

    执行log

    # gitlab-ctl reconfigure
    Starting Chef Client, version 12.12.15
    resolving cookbooks for run list: ["gitlab"]
    Synchronizing Cookbooks:
      - runit (0.14.2)
      - package (0.0.0)
      - gitlab (0.0.1)
    Installing Cookbook Gems:
    Compiling Cookbooks...
    ...
        @@ -4,7 +4,7 @@
    
         [user]
                 name = GitLab
        -        email = gitlab@22bab50a8878
    ...
         [core]
                 autocrlf = input
         [gc]
    Recipe: gitlab::gitlab-shell
    ...
        @@ -1 +1,24 @@
        +# This file is managed by gitlab-ctl. Manual changes will be
        +# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
        +# and run `sudo gitlab-ctl reconfigure`.
        +
        +if Rails.env.production?
        +  Gitlab::Application.config.action_mailer.delivery_method = :smtp
        +
        +  ActionMailer::Base.delivery_method = :smtp
        +  ActionMailer::Base.smtp_settings = {
        +    authentication: :login,
        +    address: "smtp.163.com",
        +    port: 25,
    ...
        +    domain: "163.com",
        +    enable_starttls_auto: false,
        +    
        +    
        +    openssl_verify_mode: "peer",
        +    
        +    ca_file: "/opt/gitlab/embedded/ssl/certs/cacert.pem",
        +  }
        +end
        - change mode from '' to '0644'
        - change owner from '' to 'root'
        - change group from '' to 'root'
      * link[Link /opt/gitlab/embedded/service/gitlab-rails/config/initializers/smtp_settings.rb 
    ...
    
    Running handlers:
    Running handlers complete
    Chef Client finished, 9/275 resources updated in 35 seconds
    gitlab Reconfigured!
    #
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55

    创建一个用户

    输入实际的email创建用户,此邮箱可以收到一封mail,此mail中包含初次登陆时可以进行密码设 
    定的链接。

    这里写图片描述

    log确认

    可以使用gitlab-ctl tail确认输出的日志,对问题的确认和定位很有帮助。在其中发现了发向liumiaocn@outlook.com的发送mail的信息提示。

    ==> /var/log/gitlab/gitlab-rails/production.log <==
    [ActiveJob] [ActionMailer::DeliveryJob] [7671429f-3416-446f-8a0d-63733c7bc71d] 
    Sent mail to liumiaocn@outlook.com (921.0ms)
    [ActiveJob] [ActionMailer::DeliveryJob] [7671429f-3416-446f-8a0d-63733c7bc71d] Performed ActionMailer::DeliveryJob from Sidekiq(mailers) in 1069.46ms
    
    • 1
    • 2
    • 3
    • 4
    • 5

    mail确认

    确实已经收到邮件。 
    这里写图片描述

    容易出现的问题

    邮件配置的时候容易出现”smtp sever reply:553 mail from must equal authorized user”的提示,这是因为设置的用户和实际发送邮件的用户不一致所致,因为default的邮箱需要重新设定一下,gitlab_email_from一定不要忘记设定。

    总结

    通过设定gitlab.rb,使用gitlab-ctl reconfigure使其生效,创建用户时就能确认是否能够收到email了。

    http://www.woaipu.com/shops/zuzhuan/61406
    http://www.znds.com/tv-967956-1-1.html
    http://www.znds.com/tv-967958-1-1.html

  • 相关阅读:
    苹果IPhone真机开发调试
    Unity3d 错误提示 GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced
    Unity编辑器环境在Inspector面板中显示变量
    微信小程序开发
    Android 9.0 Http不能访问网络
    c#传不确定的参数个数,比如int型
    玩转@Git三剑客
    白话法律42讲-为程序员打造的专属法律武器
    uSurvival 1.41多人在线生存逃杀吃鸡类游戏源码
    NGUI: Next-Gen UI 2018.3.0f
  • 原文地址:https://www.cnblogs.com/sy646et/p/7198102.html
Copyright © 2011-2022 走看看