GitLab email sending issues

Credit doesn't goes to me, google helps. if you have setup your gitlab on your cpanel setup, you will most likely be using apache and sendmail on gitlab. And one of the issue you will be seeing is that your gitlab email won't be sending to your receiver.

Solution

fire the following code

cp /home/git/gitlab/config/initializers/smtp_settings.rb.sample /home/git/gitlab/config/initializers/smtp_settings.rb

the above code copy the sample file to the actual smtp configure file. next we will need to open up the smtp file

vi /home/git/gitlab/config/initializers/smtp_settings.rb

and starts editing

  ActionMailer::Base.smtp_settings = {
    address: "email.server.com",
    port: 456,
    user_name: "smtp",
    password: "123456",
    domain: "gitlab.company.com",
    authentication: :login,
    enable_starttls_auto: true
  }

take note, all you have to change are the following parameters

    address: "email.server.com",
    port: 456,
    user_name: "smtp",
    password: "123456",
    domain: "gitlab.company.com",

and if you are not using https, change enable_starttls_auto to false. now restart your gitlab

root@monitor [/home/git/gitlab/config/initializers]# service gitlab restart
Stopping unicorn:                                          [  OK  ]
Stopping sidekiq:                                          [  OK  ]
Starting unicorn:                                          [  OK  ]
Starting sidekiq:                                          [  OK  ]

now go test your email, should work now!

GITLAB ERROR “FATAL: THE REMOTE END HUNG UP UNEXPECTEDLY”

If you are setting up your gitlab behind an apache server as described on my previous article, you will soon find out that you cannot push up your code into your gitlab and gitlab will throw you the following error

➜  test git:(master) ✗ git push -u origin master
Counting objects: 300, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (290/290), done.
Writing objects: 100% (300/300), 19.19 MiB | 3.83 MiB/s, done.
Total 300 (delta 14), reused 0 (delta 0)
error: RPC failed; result=22, HTTP code = 502
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date

However, if you try to push a single file change, you can safely push the code without getting any kind of annoying errors.

Solution

In order for you to push your code into your gitlab apache setup you will need to do 2 things.

Firstly you will need to run the below code on your client side (your computer!)

git config http.postBuffer 104857600

And the second steps you will need to do is to increase the timeout on gitlab! On the server, open the file unicore.rb

vim /home/git/gitlab/config/unicorn.rb

and look for the line

 38 # NOTICE: git push over http depends on this value.
 39 # If you want be able to push huge amount of data to git repository over http
 40 # you will have to increase this value too.
 41 #
 42 # Example of output if you try to push 1GB repo to GitLab over http.
 43 #   -> git push http://gitlab.... master
 44 #
 45 #   error: RPC failed; result=18, HTTP code = 200
 46 #   fatal: The remote end hung up unexpectedly
 47 #   fatal: The remote end hung up unexpectedly
 48 #
 49 # For more information see http://stackoverflow.com/a/21682112/752049
 50 #
 51 timeout 30

at line 30, you will see that you will need to change this number to something bigger, for my case, i changed it to 3600 (1 hour)

 38 # NOTICE: git push over http depends on this value.
 39 # If you want be able to push huge amount of data to git repository over http
 40 # you will have to increase this value too.
 41 #
 42 # Example of output if you try to push 1GB repo to GitLab over http.
 43 #   -> git push http://gitlab.... master
 44 #
 45 #   error: RPC failed; result=18, HTTP code = 200
 46 #   fatal: The remote end hung up unexpectedly
 47 #   fatal: The remote end hung up unexpectedly
 48 #
 49 # For more information see http://stackoverflow.com/a/21682112/752049
 50 #
 51 timeout 3600

after you have updated this value, you will need to restart gitlab!

root@monitor [/etc/httpd/conf]# service gitlab restart
Stopping unicorn:                                          [  OK  ]
Stopping sidekiq:                                          [  OK  ]
Starting unicorn:                                          [  OK  ]
Starting sidekiq:                                          [  OK  ]

Once you restarted gitlab, try to push your code again, you should be getting this

➜  test git:(master) ✗ git push -u origin master
Counting objects: 300, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (290/290), done.
Writing objects: 100% (300/300), 19.19 MiB | 5.29 MiB/s, done.
Total 300 (delta 14), reused 0 (delta 0)
To http://git.test.com/claylua/test.git
 * [new branch]      master -> master

don't you just hate apache when everyone is using nginx for gitlab? haha..

*************************************** UPDATE ********************************

*shy* i'm also using nginx now lol for reverse proxy... if everything above doesn't work, go to your nginx configuration and adjust your client_max_body_size

http {
    # ...
    client_max_body_size 16M;
    # ...

increasing this will allow your data to be send over to your server safely!