How to upgrade Gitlab 5.4 to 6.0 on CentOS 6 or RHEL6

Last modified: [last-modified]

The upgrade instructions found on Gitlab’s official website are what I followed to upgrade my installation of Gitlab.

The only alterations I’ve made are to match my unique configuration from earlier articles on this website.

If you haven’t already upgrade your Gitlab to 5.4 before proceeding with these instructions. I never wrote a 5.2 -> 5.3 or a 5.3 -> 5.4 upgrade guide. The procedure was fairly straight forward and I just followed the official documents offered by Gitlab and referred to my earlier upgrade posts for 5.0 -> 5.1 and 5.1 -> 5.2.

1. Backup all of your Gitlab Data first. I ran these commands but ended up with an error. I run other separate backups so I wasn’t concerned. You may have better luck.

[[email protected] ~]# su - sa_gitlab
[[email protected] ~]$ cd ~/gitlab
[[email protected] gitlab]$ RAILS_ENV=production bundle exec rake gitlab:backup:create

 

2. Switch back to root and install a missing dependency and shutdown Gitlab and then switch back to sa_gitlab

[[email protected] gitlab]$ exit

[[email protected] ~]# yum install python-docutils

[[email protected] ~]# service gitlab stop
# Wait 1-2 minutes for everything to shut down

[[email protected] ~]# su - sa_gitlab

 

3. Download the latest code

[[email protected] ~]$ cd ~/gitlab
[[email protected] gitlab]$ git fetch
[[email protected] gitlab]$ git stash
[[email protected] gitlab]$ git checkout 6-0-stable

 

4. Update Gitlab Shell

[[email protected] gitlab]$ cd ~/gitlab-shell/
[[email protected] gitlab-shell]$ git fetch
[[email protected] gitlab-shell]$ git checkout v1.7.0

 

5. Update Gitlab

[[email protected] ~]$ cd ~/gitlab
[[email protected] gitlab]$ bundle install --without development test postgres --deployment
[[email protected] gitlab]$ bundle exec rake db:migrate RAILS_ENV=production
[[email protected] gitlab]$ bundle exec rake migrate_groups RAILS_ENV=production
# When prompted choose 'Yes'

[[email protected] gitlab]$ bundle exec rake migrate_global_projects RAILS_ENV=production
[[email protected] gitlab]$ bundle exec rake migrate_keys RAILS_ENV=production
# When prompted choose 'Yes'

[[email protected] gitlab]$ bundle exec rake migrate_inline_notes RAILS_ENV=production
[[email protected] gitlab]$ bundle exec rake assets:precompile RAILS_ENV=production

 

6. Backup your old configuration files

[[email protected] gitlab]$ cd config
[[email protected] config]$ mv gitlab.yml gitlab.yml.54
[[email protected] config]$ mv unicorn.rb unicorn.rb.54

 

7. Create new configuration files

[[email protected] config]$ cp gitlab.yml.example gitlab.yml
[[email protected] config]$ cp unicorn.rb.example unicorn.rb

# Now move all of your settings from the .54 backups we just made into the new files
# There are a lot of new lines in the unicorn.rb that need to be changed from '/home/git' to '/data/apps/sa_gitlab'
# There is no longer a need to comment out the socket line in unicorn.rb

 

8. Update the init script

[[email protected] config]$ exit

[[email protected] ~]# cd /etc/init.d/
[[email protected] init.d]# mv gitlab gitlab.54
[[email protected] init.d]# curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlabhq/master/lib/support/init.d/gitlab
[[email protected] init.d]# chmod +x /etc/init.d/gitlab
[[email protected] init.d]# vim gitlab

# -------- Make the following edits --------

APP_ROOT="/data/apps/sa_gitlab/gitlab"
APP_USER="sa_gitlab"

# -------- Save and close the file --------

 

9. Start-up Gitlab 6!

[[email protected] init.d]# service gitlab start

# The start-up took a few minutes on my system

 

That’s it!

How to upgrade Gitlab 5.1 to 5.2 on CentOS 6 or RHEL6

Last modified: [last-modified]

This document assumes you’ve followed my previous post for deploying Gitlab on CentOS 6/RHEL6 and have already upgraded that deployment from 5.0 to 5.1.

If you haven’t already switched from the default version (1.7.1) of git that comes with CentOS 6 / RHEL6 to git 1.8.2.3 please follow this post first before continuing with these instructions. Even if you don’t care about that error message follow the instructions so you’re using git 1.8.2.3 instead of 1.7.1.

Now then. Lets get to it.

1. Stop gitlab and switch to sa_gitlab

[[email protected] ~] service gitlab stop
[[email protected] ~] ps aux |grep git
[[email protected] ~] su - sa_gitlab

 

2. Get the latest code for Gitlab and Gitlab-shell

[[email protected] ~] cd gitlab
[[email protected] gitlab] git fetch

# If you get an error about schema.rb run these two commands and then re-run 'git checkout 5-2-stable'. Otherwise skip these two commands (it won't hurt anything if you run them though)
[[email protected] gitlab] cp db/schema.rb db/schema.rb.current
[[email protected] gitlab] git stash

[[email protected] gitlab] git checkout 5-2-stable
[[email protected] gitlab] cd ..
[[email protected] ~] cd gitlab-shell/
[[email protected] gitlab-shell] git fetch
[[email protected] gitlab-shell] git checkout v1.4.0

 

3. Install libs, migrations, etc? (I stole this from the Gitlab guys)

[[email protected] gitlab-shell] cd ..
[[email protected] ~] cd gitlab
[[email protected] gitlab] bundle install --without development test postgres --deployment
[[email protected] gitlab] bundle exec rake db:migrate RAILS_ENV=production

 

4. Switch back to root and update the init script

[[email protected] gitlab] exit
[[email protected] ~] mv /etc/init.d/gitlab /etc/init.d/gitlab.51
[[email protected] ~] wget "https://raw.github.com/gitlabhq/gitlabhq/5-2-stable/lib/support/init.d/gitlab" -O /etc/init.d/gitlab
[[email protected] ~] vim /etc/init.d/gitlab

# -------- Make the following edits --------

	APP_ROOT="/data/apps/sa_gitlab/gitlab"
	APP_USER="sa_gitlab"

# -------- Save and close the file --------

[[email protected] ~] chmod 755 /etc/init.d/gitlab

 

5. Start up Gitlab

[[email protected] ~] service gitlab start

 

You should be good to go at this point. The first load took a while for me after the update.

 

References

Commit comments not appearing in Gitlab on CentOS

Last modified: [last-modified]

If you followed my earlier documentation, or simply installed Gitlab yourself on CentOS 6 you might run into this problem:

When you go to the ‘Files’ view of one of your repositories it won’t load any of the commit comments. It just appears to perpetually load.

If you look in your ‘production.log’ you’ll see an error like this:

Processing by RefsController#logs_tree as JS
  Parameters: {"_"=>"1369162443960", "project_id"=>"USERNAME/geoip-lookup", "id"=>"master"}
  Rendered refs/logs_tree.js.haml (57.2ms)
Completed 500 Internal Server Error in 98ms

ActionView::Template::Error (undefined method `committed_date' for nil:NilClass):
    4:
    5:   :plain
    6:     var row = $("table.table_#{@hex_path} tr.file_#{hexdigest(file_name)}");
    7:     row.find("td.tree_time_ago").html('#{escape_javascript time_ago_in_words(commit.committed_date)} ago');
    8:     row.find("td.tree_commit").html('#{escape_javascript render("tree/tree_commit_column", commit: commit)}');
  app/views/refs/logs_tree.js.haml:7:in `block in _app_views_refs_logs_tree_js_haml__4074553552003765415_53128340'
  app/views/refs/logs_tree.js.haml:1:in `each'
  app/views/refs/logs_tree.js.haml:1:in `_app_views_refs_logs_tree_js_haml__4074553552003765415_53128340'

It looks like this is a bug with git itself and not Gitlab.

There is a patch you can manually apply to your Gitlab deployment OR you could just upgrade git to the latest and greatest version. I chose to upgrade git. The below guide assumes you followed my original “How to install Gitlab 5.0 on CentOS 6 or RHEL6” guide. I’ve updated that guide to reflect these new steps.

1. Get logged in to your server and become ‘sa_gitlab’

[[email protected] ~] su - sa_gitlab
[[email protected]~]

 

2. Create a temp directory if you don’t have one and move into it

[[email protected]~] mkdir temp
[[email protected]~] cd temp

 

3. Download the latest source for git from https://code.google.com/p/git-core/downloads/list. As of this writing 1.8.2.3 is the latest version

[[email protected]~] wget -c https://git-core.googlecode.com/files/git-1.8.2.3.tar.gz
[[email protected]~] tar -xf git-1.8.2.3.tar.gz
[[email protected]~] cd git-1.8.2.3

 

4. Configure, compile and install git 1.8.2.3

[[email protected]~] ./configure --prefix=/data/apps/sa_gitlab/git
[[email protected]~] make
[[email protected]~] make install

 

5. Configure your environment so the new version of git overrides the default CentOS version

[[email protected]~] vim ~/.bashrc

# -------- Make the following edits --------

# Change the PATH line to look like this:
PATH=$HOME/git/bin:$HOME/ruby/bin:$PATH:$HOME/bin;

# -------- Save and close the file --------

[[email protected]~] vim ~/.bash_profile

# -------- Make the following edits --------

# Change the PATH line to look like this:
PATH=$HOME/git/bin:$HOME/ruby/bin:$PATH:$HOME/bin;

# -------- Save and close the file --------

 

6. Re-export your path and verify which git is being used and it’s version

[[email protected]~] PATH=$HOME/git/bin:$HOME/ruby/bin:$PATH:$HOME/bin;

[[email protected]~] which git
~/git/bin/git

[[email protected] ~] git --version
git version 1.8.2.3

 

7. Update your gitlab.yml configuration file

[[email protected] ~] cd gitlab
[[email protected] gitlab] vim config/gitlab.yml

# -------- Make the following edits --------

  git:
    bin_path: /data/apps/sa_gitlab/git/bin/git

# -------- Save and close the file --------

 

8. Restart Gitlab

[[email protected] gitlab] exit

[[email protected] ~] service gitlab stop

# Wait 1-2 minutes for everything to exit

[[email protected] ~] service gitlab start

 

That’s it!

Update May 22nd, 2013 – Added step 7. Didn’t realise you had to edit the gitlab.yml file to point to the new git binary location. I assumed Gitlab used the git binary it found via PATH.

How to upgrade Gitlab 5.0 to 5.1 on CentOS 6 or RHEL6

Last modified: [last-modified]

These are instructions on how to upgrade Gitlab 5.0 to 5.1 on CentOS 6.

This guide assumes you already followed my How to install Gitlab 5.0 on CentOS 6 or RHEL6 post.

  1. As the root user stop the Gitlab service
    [[email protected] ~] service gitlab stop
    # Wait a few moments before continuing. Shutting down Gitlab took 30sec-1min on my system.

     

  2. Switch to the ‘sa_gitlab’ user account and move into your gitlab directory
    [[email protected] ~] su - sa_gitlab
    [[email protected]~] cd gitlab

     

  3. Update Gitlab source from 5.0 to 5.1
    [[email protected]~] git fetch
    [[email protected]~] git checkout 5-1-stable

     

  4. Configure Puma which is replacing Unicorn
    [[email protected]~] cp config/puma.rb.example config/puma.rb
    [[email protected]~] vim config/puma.rb
    
    # -------- Make the following edits --------
    
      application_path = '/data/apps/sa_gitlab/gitlab'
      bind 'tcp://127.0.0.1:65527'
    
    # -------- Save and close the file --------

     

  5. Redeploy Gitlab (I think that’s what this does anyway)
    # You may not need to do this. I ran into some errors during my upgrade but my ISP was having problems at the time. It won't hurt to run these commands either way.
    [[email protected]~] gem install sanitize -v '2.0.3'
    [[email protected]~] gem install jquery-rails -v '2.1.3'
    
    # These commands you DO need to run
    [[email protected]~] bundle install --without development test postgres --deployment
    [[email protected]~] bundle exec rake db:migrate RAILS_ENV=production
    [[email protected]~] bundle exec rake migrate_merge_requests RAILS_ENV=production
    # When prompted choose 'Yes'

     

  6. Switch back to root and update the Gitlab start-up script
    [[email protected]~] exit
    
    [[email protected] ~] mv /etc/init.d/gitlab /etc/init.d/gitlab.50
    [[email protected] ~] curl --output /etc/init.d/gitlab https://raw.github.com/gitlabhq/gitlab-recipes/5-1-stable/init.d/gitlab
    [[email protected] ~] vim /etc/init.d/gitlab
    
    # -------- Make the following edits --------
    # The lines with a + are lines you need to add to the script
    
      APP_ROOT="/data/apps/sa_gitlab/gitlab"
    + APP_USER="sa_gitlab"
    
    # Search/Replace "sudo -u git" with "sudo -u $APP_USER"
    
    # -------- Save and close the file --------
    
    [[email protected] ~] chmod +x /etc/init.d/gitlab

     

  7. Start up Gitlab and then restart Apache if your using mod_proxy
    [[email protected] ~] service gitlab start
    [[email protected] ~] service httpd restart

     

  8. Update Gitlab Shell
    [[email protected] ~] su - sa_gitlab
    [[email protected]~] cd gitlab-shell
    [[email protected]~] git pull
    [[email protected]~] bin/install
    [[email protected]~] bin/check

All done! Hopefully this went slightly more smoothly for you then it did me. I noticed the first time loading Gitlab after the upgrade as a bit slow but things were nice and quick after that.

Updated April 26th, 2013 – Added instructions for updating Gitlab shell.

Updated May 22nd, 2013 – Wrote an article on How to go from 5.1 to 5.2

How to update Gitlab 5.0 in place

Last modified: [last-modified]

It’s been a few days since I deployed Gitlab following an earlier article I posted. Now I want to check for updates and apply them. It’s actually pretty straight forward.

This article assumes you followed my earlier one in how to setup Gitlab 5.0 on CentOS 6. It also only performs updates within the 5.0 branch of Gitlab. It will not get you to say 5.1 when that gets released.

  1. Stop Gitlab
    # As ROOT
    [[email protected]calhost~] service gitlab stop
  2. Switch to the Gitlab user and update Gitlab and Gitlab-shell
    [[email protected]~] su - sa_gitlab
    [[email protected]~] cd ~/gitlab
    [[email protected]~] git pull
    [[email protected]~] bundle install
    
    [[email protected]~] cd ~/gitlab-shell
    [[email protected]~] git pull
  3. Switch back to root and restart Gitlab
    # As ROOT
    [[email protected]~] service gitlab start