Gitlab CI 7.14 auf Gitlab 8.0 umstellen

340 Wörter 2 Minuten Lesezeit

Der Common Integration Server Gitlab CI wurde in die Versionsverwaltung Gitlab integriert; beim Upgrade müssen die Daten von Gitlab CI daher entsprechend in den bereits aktualisieren Gitlab 8 Server importiert werden.

Backup von Gitlab + Gitlab CI

cd /home/gitlab_ci/gitlab-ci
sudo -u gitlab_ci -H bundle exec rake backup:create RAILS_ENV=production
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production SKIP=repositories,uploads

Bestehende CI installation überprüfen

cd /home/gitlab_ci/gitlab-ci
sudo -u gitlab_ci -H bundle exec rake env:info RAILS_ENV=production

Upgrade auf CI 8

sudo service gitlab_ci stop
cd /home/gitlab_ci/gitlab-ci
sudo -u gitlab_ci -H git fetch
sudo -u gitlab_ci -H git checkout -- db/schema.rb
sudo -u gitlab_ci -H git checkout v8.0.2

sudo chmod -R u+rwX builds
sudo -u gitlab_ci -H cp config/secrets.yml.example config/secrets.yml
sudo -u gitlab_ci -H chmod 0600 config/secrets.yml

sudo sed -i 's|# secret_key_base:|secret_key_base: XXXXXXXXXX|' config/secrets.yml
sudo sed -i 's|# db_key_base:|db_key_base: XXXXXXXXXX|' config/secrets.yml

sudo -u gitlab_ci -H editor config/secrets.yml
sudo -u gitlab_ci -H bundle install --without postgres development test --deployment
sudo -u gitlab_ci -H bundle exec rake db:migrate RAILS_ENV=production
sudo service gitlab_ci start && sudo service nginx restart

CI deaktivieren

sudo service gitlab_ci stop
cd /home/gitlab_ci/gitlab-ci
sudo -u gitlab_ci -H bundle exec whenever --clear-crontab
sudo -u gitlab_ci -H bundle exec rake backup:show_secrets RAILS_ENV=production

Daten importieren

sudo mv /home/gitlab_ci/gitlab-ci/tmp/backups/1443478190_gitlab_ci_backup.tar /home/git/gitlab/tmp/backups/

cd /home/git/gitlab
sudo -u git -H bundle exec rake ci:migrate RAILS_ENV=production

Gitlab 8 neu starten

sudo service gitlab reload

nginx Webserver

sudo cp /etc/nginx/sites-available/gitlab_ci /etc/nginx/sites-available/gitlab_ci.bak

sudo vi /etc/nginx/sites-available/gitlab_ci
# GITLAB CI
server {
listen 0.0.0.0:80;
listen [::]:80;
server_name gitlab-ci.domain.tld;  # e.g., server_name source.example.com;

access_log  /var/log/nginx/gitlab_ci_access.log;
error_log   /var/log/nginx/gitlab_ci_error.log;

# expose API to fix runners
location /api {
  proxy_read_timeout    300;
  proxy_connect_timeout 300;
  proxy_redirect        off;
  proxy_set_header   X-Real-IP         $remote_addr;

  # You need to specify your DNS servers that are able to resolve YOUR_GITLAB_SERVER_FQDN
  resolver 8.8.8.8 8.8.4.4;
  proxy_pass $scheme://gitlab.domain.tld/ci$request_uri;
}

# redirect all other CI requests
location / {
  return 301 $scheme://gitlab.domain.tld/ci$request_uri;
}

# adjust this to match the largest build log your runners might submit,
# set to 0 to disable limit
client_max_body_size 10m;
}
sudo nginx -t
sudo /etc/init.d/nginx restart

Gitlab CI Dienst entfernen

sudo update-rc.d gitlab_ci remove