Removed Gitlab Upgrader found in /lib/gitlab/upgrader.rb
This commit is contained in:
parent
157bc81d27
commit
bd3c2f3aba
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
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) https://gitlab.com/gitlab-com/www-gitlab-com/merge_requests/
|
||||
1. Upgrade guide, for example https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/7.5-to-7.6.md
|
||||
1. Upgrader https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/upgrader.md#2-run-gitlab-upgrade-tool
|
||||
1. Installation guide https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.md#1-packages-dependencies
|
||||
1. GitLab Development Kit https://gitlab.com/gitlab-org/gitlab-development-kit
|
||||
1. Test suite https://gitlab.com/gitlab-org/gitlab-ce/blob/master/scripts/prepare_build.sh
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
---
|
||||
comments: false
|
||||
---
|
||||
|
||||
# GitLab Upgrader (deprecated)
|
||||
|
||||
*DEPRECATED* We recommend to [switch to the Omnibus package and repository server](https://about.gitlab.com/update/) 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](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/upgrader.md) 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](https://packages.gitlab.com/gitlab/gitlab-ce).
|
||||
|
||||
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.](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.md#1-packages-dependencies)
|
||||
|
||||
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 'Gitlab::Upgrader.new.execute'
|
||||
|
||||
# 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 'Gitlab::Upgrader.new.execute' -- -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](https://packages.gitlab.com/gitlab/gitlab-ce).
|
||||
|
||||
```bash
|
||||
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 'Gitlab::Upgrader.new.execute' -- -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
|
||||
```
|
|
@ -1,111 +0,0 @@
|
|||
# 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"
|
||||
else
|
||||
puts "Newer GitLab version is available"
|
||||
|
||||
answer = if ARGV.first == "-y"
|
||||
"yes"
|
||||
else
|
||||
prompt("Do you want to upgrade (yes/no)? ", %w{yes no})
|
||||
end
|
||||
|
||||
if answer == "yes"
|
||||
upgrade
|
||||
else
|
||||
exit 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def latest_version?
|
||||
current_version >= latest_version
|
||||
end
|
||||
|
||||
def current_version
|
||||
@current_version ||= Gitlab::VersionInfo.parse(current_version_raw)
|
||||
end
|
||||
|
||||
def latest_version
|
||||
@latest_version ||= Gitlab::VersionInfo.parse(latest_version_raw)
|
||||
end
|
||||
|
||||
def current_version_raw
|
||||
File.read(File.join(gitlab_path, "VERSION")).strip
|
||||
end
|
||||
|
||||
def latest_version_raw
|
||||
git_tags = fetch_git_tags
|
||||
git_tags = git_tags.select { |version| version =~ /v\d+\.\d+\.\d+\Z/ }
|
||||
git_versions = git_tags.map { |tag| Gitlab::VersionInfo.parse(tag.match(/v\d+\.\d+\.\d+/).to_s) }
|
||||
"v#{git_versions.sort.last}"
|
||||
end
|
||||
|
||||
def fetch_git_tags
|
||||
remote_tags, _ = Gitlab::Popen.popen(%W(#{Gitlab.config.git.bin_path} ls-remote --tags https://gitlab.com/gitlab-org/gitlab-ce.git))
|
||||
remote_tags.split("\n").grep(%r{tags/v#{current_version.major}})
|
||||
end
|
||||
|
||||
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)
|
||||
}
|
||||
end
|
||||
|
||||
def env
|
||||
{
|
||||
'RAILS_ENV' => 'production',
|
||||
'NODE_ENV' => 'production'
|
||||
}
|
||||
end
|
||||
|
||||
def upgrade
|
||||
update_commands.each do |title, cmd|
|
||||
puts title
|
||||
puts " -> #{cmd.join(' ')}"
|
||||
|
||||
if system(env, *cmd)
|
||||
puts " -> OK"
|
||||
else
|
||||
puts " -> FAILED"
|
||||
puts "Failed to upgrade. Try to repeat task or proceed with upgrade manually "
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
puts "Done"
|
||||
end
|
||||
|
||||
def gitlab_path
|
||||
File.expand_path(File.join(File.dirname(__FILE__), '../..'))
|
||||
end
|
||||
|
||||
# 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)
|
||||
begin
|
||||
print(message)
|
||||
answer = STDIN.gets.chomp
|
||||
end while !choices.include?(answer)
|
||||
answer
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,40 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Gitlab::Upgrader do
|
||||
let(:upgrader) { described_class.new }
|
||||
let(:current_version) { Gitlab::VERSION }
|
||||
|
||||
describe 'current_version_raw' do
|
||||
it { expect(upgrader.current_version_raw).to eq(current_version) }
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
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")
|
||||
end
|
||||
|
||||
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")
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue