Install
http://www.panticz.de/install-gitlab
CLI
# restart gitlab gitlab-ctl restart # git home directory /var/opt/gitlab
Reset admin password
# change root password sudo gitlab-rails console user = User.where(id: 1).first user.password = user.password_confirmation ='xxx' user.save!
Gitlab settings API
https://docs.gitlab.com/ee/api/settings.html curl --header "PRIVATE-TOKEN: 11112222333344445555" https://gitlab.example.com/api/v4/application/settings
Disalbe register / Singup
sudo gitlab-rails console ApplicationSetting.last.update_attributes(signup_enabled: false)
backup
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/backup_restore.md
# full backup gitlab-rake gitlab:backup:create # backup without reposiories sudo gitlab-rake gitlab:backup:create SKIP=repositories # backup target ls -l /var/opt/gitlab/backups gitlab_rails['backup_keep_time'] = 604800 # backup to s3 gitlab_rails['artifacts_enabled'] = true gitlab_rails['artifacts_object_store_enabled'] = true gitlab_rails['artifacts_object_store_remote_directory'] = "artifacts" gitlab_rails['artifacts_object_store_connection'] = { 'provider' => 'AWS', 'region' => 'foo-west-1', 'aws_access_key_id' => '1111111111111111111111', 'aws_secret_access_key' => '22222222222222222222222222222', 'endpoint' => 'https://s3.example.com' }
restore
sudo gitlab-rake gitlab:backup:restore force=yes https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/backup_restore.md
Send email via SMTP
https://docs.gitlab.com/omnibus/settings/smtp.html
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/smtp.md
# /etc/gitlab/gitlab.rb gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.example.com" # reconfigure GitLab gitlab-ctl reconfigure # send testmail gitlab-rails console Notify.test_email('foo@example.com', 'GitLab Test', 'Test message from GitLab server').deliver_now
Create backup
sudo gitlab-ctl stop unicorn sudo gitlab-ctl stop sidekiq sudo gitlab-ctl stop nginx sudo gitlab-rake gitlab:backup:create
CLI
gitlab-rake db:migrate gitlab-ctl reconfigure gitlab-ctl restart sudo gitlab-ctl tail sudo gitlab-ctl tail nginx gitlab-rake cache:clear gitlab-ctl hup unicorn sudo gitlab-rake gitlab:check sudo cat /var/log/gitlab/gitlab-rails/production.log sudo gitlab-rails console # get state sudo gitlab-ctl status sudo gitlab-rake gitlab:backup:restore [-v --trace]
Upgrade
https://docs.gitlab.com/ee/update/index.html#upgrade-paths
https://docs.gitlab.com/ee/update/package/
# http://www.mikeobrien.net/blog/setting-up-gitlab-with-active-directory-and-self-signed-cert/
http://www.mikeobrien.net/blog/setting-up-gitlab-with-active-directory-and-self-signed-cert/
# self signed certificate ?
https://futurestud.io/blog/how-to-run-gitlab-with-self-signed-ssl-certificate/
User management CLI
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/raketasks/user_management.md
Reset GitLab admin password
http://doc.gitlab.com/ce/security/reset_root_password.html
Logs
https://github.com/gitlabhq/omnibus-gitlab/blob/master/doc/settings/logs.md
sudo gitlab-ctl tail sudo gitlab-ctl tail gitlab-rails sudo gitlab-ctl tail nginx/gitlab_error.log tail -f /var/log/gitlab/gitlab-rails/*.log cat /var/log/gitlab/gitlab-rails/application.log
Fix: Could not authorize you from LDAP because "Undefined method `persisted?' for ...
-- login to Gitlab DB (MySql) mysql -u gitlab gitlabhq_production -p select email from users where username like 'foo'; update users set extern_uid = '' where username = 'foo';
Database
-- login to DB (Omnibus Postgres Database) sudo gitlab-rails dbconsole # OR (old?) su gitlab-psql -c "/opt/gitlab/embedded/bin/psql gitlabhq_production" select extern_uid from identities where extern_uid like '%foo%'; delete from identities where extern_uid like '%foo%'; commit
check if postgress is running
sudo netstat -anp | grep 5432
Change logo
http://jo-ke.name/wp/?p=156&lang=de
/opt/gitlab/embedded/service/gitlab-rails/app/helpers/appearances_helper.rb
/opt/gitlab/embedded/service/gitlab-rails/app/views/layouts/devise.html.haml
add
%img{:src => "/assets/logo.svg"}
copy image to
/opt/gitlab/embedded/service/gitlab-rails/public/assets/logo.svg
# disable migration after update
sudo touch /etc/gitlab/skip-auto-migrations
Markdown
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/markdown/markdown.md#url-auto-linking
Links
https://www.omniref.com/github/gitlabhq/omnibus-gitlab/7.1.1.omnibus
https://gitlab.com/gitlab-org/cookbook-gitlab/blob/master/attributes/default.rb
binary
/opt/gitlab/embedded/bin/git
grep
cd /var/opt/gitlab/git-data/repositories/foo for REPO in $(ls); do (cd ${REPO}; /opt/gitlab/embedded/bin/git grep bar HEAD) done # enable GitLab SSL # https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/nginx.md sed -i 's/http/https/g' /etc/gitlab/gitlab.rb sudo mkdir -p /etc/gitlab/ssl sudo chmod 700 /etc/gitlab/ssl # create self signed key openssl \ req \ -x509 \ -newkey rsa:2048 \ -sha256 \ -nodes \ -days 365 \ -keyout /etc/gitlab/ssl/$(hostname -f).key \ -out /etc/gitlab/ssl/$(hostname -f).crt \ -subj "/C=DE/ST=NRW/L=Koeln/O=Example Inc/OU=IT/CN=$(hostname -f)/emailAddress=info@$(hostname -f)" cat <<EOF>> /etc/gitlab/gitlab.rb external_url "https://$(hostname -f)" nginx['redirect_http_to_https'] = true nginx['ssl_certificate'] = "/etc/letsencrypt/live/$(hostname -f)/fullchain.pem" nginx['ssl_certificate_key'] = "/etc/letsencrypt/live/$(hostname -f)/privkey.pem" EOF sudo gitlab-ctl reconfigure gitlab-ctl restart nginx # renew Letsencrypt SSL certificate cd /etc/gitlab/ssl cp /tmp/example.com/fullchain1.pem git.example.com.crt cp /tmp/example.com/privkey1.pem git.example.com.key gitlab-ctl restart nginx gitlab-ctl restart nginx gitlab-ctl tail nginx
GitLab markdown
https://docs.gitlab.com/ee/user/markdown.html
Api
https://docs.gitlab.com/ee/api/repository_files.html
Send test email
sudo gitlab-rails console Notify.test_email('foo@example.com', 'Message Subject', 'Message Body').deliver_now
GitLab CE API
https://docs.gitlab.com/ce/api/
Settings
# get current settings (login as admin firs)
https://git.example.com/api/v4/application/settings
Registry
http://www.panticz.de/gitlab-registry-s3-storage
cleanup registry (test):
sudo gitlab-ctl registry-garbage-collect sudo gitlab-ctl restart registry
# Personal Access Tokens https://gitlab.example.com/profile/personal_access_tokens # check out single file with token curl --silent --request GET --header 'PRIVATE-TOKEN: 1234567890' 'http://git.example.com/foo/bar/file1.sql' --output /tmp/file1.sql # download single file with token curl --header 'PRIVATE-TOKEN: bar123' 'https://gitlab.example.ch/foo/bar/raw/master/file.json' curl "https://gitlab.example.ch/foo/bar/raw/master/file.json?private_token=bar123" # fix mime-type output for rundeck sed -i "s| if blob.extension == 'svg'| if blob.extension.in?(['svg','json'])|g" /opt/gitlab/embedded/service/gitlab-rails/app/helpers/blob_helper.rb # Download single RAW file by API https://docs.gitlab.com/ee/api/repository_files.html#get-file-from-repository # encode URL file (https://meyerweb.com/eric/tools/dencoder/) https://git.example/api/v4/projects/3/repository/files/ProjectX%2Fdev%2Foptions-hosts.json/raw?ref=master&private_token=${globals.private_token}