Commit bd3c2f3a authored by Jacob Wolen's avatar Jacob Wolen Committed by Lin Jen-Shin

Removed Gitlab Upgrader found in /lib/gitlab/upgrader.rb

parent 157bc81d
title: Removes all instances of deprecated Gitlab Upgrader calls
merge_request: 23603
author: '@jwolen'
type: removed
......@@ -179,7 +179,6 @@ merge request:
1. Note the addition in the release blog post (create one if it doesn't exist yet)
1. Upgrade guide, for example
1. Upgrader
1. Installation guide
1. GitLab Development Kit
1. Test suite
comments: false
# GitLab Upgrader (deprecated)
*DEPRECATED* We recommend to [switch to the Omnibus package and repository server]( instead of using this script.
Although deprecated, if someone wants to make this script into a gem or otherwise improve it merge requests are welcome.
*Make sure you view this [upgrade guide from the 'master' branch]( for the most up to date instructions.*
GitLab Upgrader - a ruby script that allows you easily upgrade GitLab to latest minor version.
For example it can update your application from 6.4 to latest GitLab 6 version (like 6.6.1).
You still need to create a backup and manually restart GitLab after running the script but all other operations are done by this upgrade script.
If you have local changes to your GitLab repository the script will stash them and you need to use `git stash pop` after running the script.
**GitLab Upgrader is available only for GitLab version 6.4.2 or higher.**
**This script does NOT update gitlab-shell, it needs manual update. See step 5 below.**
## 0. Backup
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
## 1. Stop server
sudo service gitlab stop
## 2. Run GitLab upgrade tool
Please replace X.X.X with the [latest GitLab release](
GitLab 7.9 adds `nodejs` as a dependency. GitLab 7.6 adds `libkrb5-dev` as a dependency (installed by default on Ubuntu and OSX). GitLab 7.2 adds `pkg-config` and `cmake` as dependency. Please check the dependencies in the [installation guide.](
cd /home/git/gitlab
sudo -u git -H ruby -Ilib -e 'require "gitlab/upgrader"' -e 'class Gitlab::Upgrader' -e 'def latest_version_raw' -e '"vX.X.X"' -e 'end' -e 'end' -e ''
# to perform a non-interactive install (no user input required) you can add -y
# sudo -u git -H ruby -Ilib -e 'require "gitlab/upgrader"' -e 'class Gitlab::Upgrader' -e 'def latest_version_raw' -e '"vX.X.X"' -e 'end' -e 'end' -e '' -- -y
## 3. Start application
sudo service gitlab start
sudo service nginx restart
## 4. Check application status
Check if GitLab and its dependencies are configured correctly:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
If all items are green, then congratulations upgrade is complete!
## 5. Upgrade GitLab Shell
GitLab Shell might be outdated, running the commands below ensures you're using a compatible version:
cd /home/git/gitlab-shell
sudo -u git -H git fetch
sudo -u git -H git checkout v`cat /home/git/gitlab/GITLAB_SHELL_VERSION`
sudo -u git -H sh -c 'if [ -x bin/compile ] ; then bin/compile ; fi'
## One line upgrade command
You've read through the entire guide and probably already did all the steps one by one.
Below is a one line command with step 1 to 5 for the next time you upgrade.
Please replace X.X.X with the [latest GitLab release](
cd /home/git/gitlab; \
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production; \
sudo service gitlab stop; \
sudo -u git -H ruby -Ilib -e 'require "gitlab/upgrader"' -e 'class Gitlab::Upgrader' -e 'def latest_version_raw' -e '"vX.X.X"' -e 'end' -e 'end' -e '' -- -y; \
cd /home/git/gitlab-shell; \
sudo -u git -H git fetch; \
sudo -u git -H git checkout v`cat /home/git/gitlab/GITLAB_SHELL_VERSION`; \
sudo -u git -H sh -c 'if [ -x bin/compile ] ; then bin/compile ; fi'; \
cd /home/git/gitlab; \
sudo service gitlab start; \
sudo service nginx restart; \
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
\ No newline at end of file
# frozen_string_literal: true
module Gitlab
class Upgrader
def execute
puts "GitLab #{current_version.major} upgrade tool"
puts "Your version is #{current_version}"
puts "Latest available version for GitLab #{current_version.major} is #{latest_version}"
if latest_version?
puts "You are using the latest GitLab version"
puts "Newer GitLab version is available"
answer = if ARGV.first == "-y"
prompt("Do you want to upgrade (yes/no)? ", %w{yes no})
if answer == "yes"
exit 0
def latest_version?
current_version >= latest_version
def current_version
@current_version ||= Gitlab::VersionInfo.parse(current_version_raw)
def latest_version
@latest_version ||= Gitlab::VersionInfo.parse(latest_version_raw)
def current_version_raw, "VERSION")).strip
def latest_version_raw
git_tags = fetch_git_tags
git_tags = { |version| version =~ /v\d+\.\d+\.\d+\Z/ }
git_versions = { |tag| Gitlab::VersionInfo.parse(tag.match(/v\d+\.\d+\.\d+/).to_s) }
def fetch_git_tags
remote_tags, _ = Gitlab::Popen.popen(%W(#{Gitlab.config.git.bin_path} ls-remote --tags
def update_commands
"Stash changed files" => %W(#{Gitlab.config.git.bin_path} stash),
"Get latest code" => %W(#{Gitlab.config.git.bin_path} fetch),
"Switch to new version" => %W(#{Gitlab.config.git.bin_path} checkout v#{latest_version}),
"Install gems" => %w(bundle),
"Migrate DB" => %w(bundle exec rake db:migrate),
"Recompile assets" => %w(bundle exec rake yarn:install gitlab:assets:clean gitlab:assets:compile),
"Clear cache" => %w(bundle exec rake cache:clear)
def env
'RAILS_ENV' => 'production',
'NODE_ENV' => 'production'
def upgrade
update_commands.each do |title, cmd|
puts title
puts " -> #{cmd.join(' ')}"
if system(env, *cmd)
puts " -> OK"
puts " -> FAILED"
puts "Failed to upgrade. Try to repeat task or proceed with upgrade manually "
exit 1
puts "Done"
def gitlab_path
File.expand_path(File.join(File.dirname(__FILE__), '../..'))
# Prompt the user to input something
# message - the message to display before input
# choices - array of strings of acceptable answers or nil for any answer
# Returns the user's answer
def prompt(message, choices = nil)
answer = STDIN.gets.chomp
end while !choices.include?(answer)
require 'spec_helper'
describe Gitlab::Upgrader do
let(:upgrader) { }
let(:current_version) { Gitlab::VERSION }
describe 'current_version_raw' do
it { expect(upgrader.current_version_raw).to eq(current_version) }
describe 'latest_version?' do
it 'is true if newest version' do
allow(upgrader).to receive(:latest_version_raw).and_return(current_version)
expect(upgrader.latest_version?).to be_truthy
describe 'latest_version_raw' do
it 'is the latest version for GitLab 5' do
allow(upgrader).to receive(:current_version_raw).and_return("5.3.0")
expect(upgrader.latest_version_raw).to eq("v5.4.2")
it 'gets the latest version from tags' do
allow(upgrader).to receive(:fetch_git_tags).and_return([
'6f0733310546402c15d3ae6128a95052f6c8ea96 refs/tags/v7.1.1',
'facfec4b242ce151af224e20715d58e628aa5e74 refs/tags/v7.1.1^{}',
'f7068d99c79cf79befbd388030c051bb4b5e86d4 refs/tags/v7.10.4',
'337225a4fcfa9674e2528cb6d41c46556bba9dfa refs/tags/v7.10.4^{}',
'880e0ba0adbed95d087f61a9a17515e518fc6440 refs/tags/v7.11.1',
'6584346b604f981f00af8011cd95472b2776d912 refs/tags/v7.11.1^{}',
'43af3e65a486a9237f29f56d96c3b3da59c24ae0 refs/tags/v7.11.2',
'dac18e7728013a77410e926a1e64225703754a2d refs/tags/v7.11.2^{}',
'0bf21fd4b46c980c26fd8c90a14b86a4d90cc950 refs/tags/v7.9.4',
'b10de29edbaff7219547dc506cb1468ee35065c3 refs/tags/v7.9.4^{}'
expect(upgrader.latest_version_raw).to eq("v7.11.2")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment