Skip to content
Search

GitLab

lastmod 2025-12-08created 2015-02-0589 edits

Version Control on your Server like GitHub but Open Source!!

Category

How to install

CentOS

Based on CentOS7, set it up as follows.

$ sudo yum install openssh-server
$ sudo systemctl enable sshd
$ sudo systemctl start sshd
$ sudo yum install postfix
$ sudo systemctl enable postfix
$ sudo systemctl start postfix
$ sudo firewall-cmd --permanent --add-service=http
$ sudo systemctl reload firewalld

Then download the Omnibus package.

$ curl -O https://downloads-packages.s3.amazonaws.com/centos-7.0.1406/gitlab-7.7.2_omnibus.5.4.2.ci-1.el7.x86_64.rpm
$ sudo rpm -i gitlab-7.7.2_omnibus.5.4.2.ci-1.el7.x86_64.rpm

Edit the configuration file if needed.

$ sudo vi /etc/gitlab/gitlab.rb

Start the service.

$ sudo gitlab-ctl reconfigure

For reference, on CentOS the install location is /opt/gitlab/.

Ubuntu

$ sudo apt-get install curl openssh-server ca-certificates postfix
$ curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
$ sudo apt-get install gitlab-ce
$ sudo gitlab-ctl reconfigure

Configuration

Enable HTTPS

If you want to apply HTTPS with the default settings, just change the protocol of external_url to https as below.

# note the 'https' below
external_url "https://admin.server-project.com"

If you want to specify the public key location, use the properties below.

# For GitLab
nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.example.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.example.com.key"

Then place the public key certificate1 created for the domain name above as follows.

$ sudo mkdir -p /etc/gitlab/ssl
$ sudo chmod 700 /etc/gitlab/ssl

Create a new public key by referring to OpenSSL#How to create a certificate. Simply put, you can do it as follows.

$ sudo -s
$ cd /etc/gitlab/ssl
$ openssl req -x509 -sha256 -nodes -days 3650 -newkey rsa:2048 -keyout private.key -out certificate.crt

Gitlab in Docker

On initial installation, the administrator ID is root.

Testing the SMTP configuration

You can verify GitLab's ability to send emails properly using the Rails console. On the GitLab server, execute gitlab-rails console to enter the console. Then, you can enter the following command at the console prompt to cause GitLab to send a test email:

irb(main):003:0> Notify.test_email('[email protected]', 'Message Subject', 'Message Body').deliver_now

How to uninstall

You can remove it as follows.

# Stop gitlab and remove its supervision process
$ sudo gitlab-ctl uninstall

# Redhat/Centos
$ sudo rpm -e gitlab

# To remove all omnibus-gitlab data use
$ sudo gitlab-ctl cleanse

# To remove all users and groups created by omnibus-gitlab
$ sudo gitlab-ctl remove_users

How to update

## 실행중인 GitLab 서비스 중단.
$ sudo gitlab-ctl stop unicorn
$ sudo gitlab-ctl stop sidekiq
$ sudo gitlab-ctl stop nginx

## GitLab 백업하기.
sudo gitlab-rake gitlab:backup:create

## GitLab 업그레이드 하기.
sudo yum install gitlab-ce

## GitLab Repository 재설정 및 서버 재시작.
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart

How to backup

## GitLab 백업하기.
## - /etc/gitlab/gitlab.rb 에 gitlab_rails['backup_path'] 변수에 정의된 경로로 백업데이터가 저장된다.
## - 기본 백업 디렉토리는 /var/opt/gitlab/backups
$ sudo gitlab-rake gitlab:backup:create

(LEGACY!!) Restore as follows. <del>

$ sudo gitlab-ctl stop unicorn
$ sudo gitlab-ctl stop sidekiq

## Verify
$ sudo gitlab-ctl status

## Next, restore the backup, specifying the timestamp of the backup you wish to restore:
## This command will overwrite the contents of your GitLab database!
$ sudo gitlab-rake gitlab:backup:restore BACKUP=1393513186

## Restart!
$ sudo gitlab-ctl start

</del>

If you restore as below, the Timestamps in the backup directory are checked and the latest backup is used for the restore.

## Stop processes that are connected to the database
$ sudo service gitlab stop

## Restore
$ bundle exec rake gitlab:backup:restore RAILS_ENV=production

## Next, restore /home/git/gitlab/.secret if necessary as mentioned above.
## ...

## Restart GitLab:
$ sudo service gitlab restart

WARNING

Note that backup and migration are different! If the version of the backed-up data differs from the current GitLab version, it cannot be restored properly.

Restore for Docker image and gitlab-omnibus helm chart

For docker installations, the restore task can be run from host using the command

$ docker exec -it <name of container> gitlab-rake gitlab:backup:restore

Creating a branch from issue in GitLab

If you create a branch named <issue-number>-issue-description and push it to gitlab, it is automatically linked to that Issue. For example, if there is an Issue with ID 654 and you create a branch named 654-some-feature and push it to gitlab, it is linked to Issue 654.

Gitlab asks whether you want to create a merge request, and automatically adds Closes #654 to the merge request description, which closes issue 654 when the merge request is accepted.

Also, when you go to a specific issue page in gitlab, you should see a New Branch button that automatically creates a branch named in the <issue-number>-issue-description format.

From the GitLab documentation

Prefix a branch name with an issue number to streamline merge request creation. When you create a merge request for a branch with a name beginning with an issue number, GitLab:

  • Marks the issue as related. If your project is configured with a default closing pattern, merging this merge request also closes the related issue.
  • Copies label and milestone metadata from the issue.

Time tracking

You can use Quick Actions in the issue description and comment boxes.

  • /estimate - Updates the estimated time.
  • /spend - Updates the total time actually spent.

Auto DevOps

Auto DevOps detects the programming language and uses CI/CD templates to create and run default pipelines that build and test the application.

You can then configure deployments to deploy the app to staging and production, and set up Review Apps to preview changes per branch.

How to disable

To enable (or disable) Auto DevOps for all projects:

  1. On the left sidebar, at the bottom, select Admin.
  2. Select Settings > CI/CD.
  3. Check (or uncheck to disable) the box that says Default to Auto DevOps pipeline for all projects.
  4. Optionally, set up the Auto DevOps base domain which is used for Auto Deploy and Auto Review Apps.
  5. Select Save changes for the changes to take effect.

Example

sudo gitlab-ctl status
Check the current status of GitLab.
sudo gitlab-rake gitlab:env:info
Check GitLab's version information.

GitLab Systems Diagram

All the Tech Stack Applications GitLab uses internally. A good reference for what solutions a fully remote company uses. A separate Google Sheet summarizes at a glance the product (link), purpose of use, access permissions, group/business/technical owner, what data it collects, whether it is customer-facing or employee-facing, and so on

  • Finance : Stripe, NetApp, Zuora, ADP, Blackline, Expensify, Clari, Carta, Xactly, Avalara, "CloudExtend: Gdrive for NetSuite", NetSuite
  • Sales : Salesforce, Chrous.ai, Clari, OwnBackup, Sertifi
  • PeopleOps : Zoom, Gmail, Calendly, Beamy, Lumity, Beeterment, Teleport, Moo, Bonusly, Slack, NexTravel, Crowdin, Will Interactive, CultureAmp, Greenhouse
  • Data Team : Data warehouse, Periscope
  • Product : GitLab, dev.gitlab, customers.gitlab, license.gitlab, version.gitlab
  • Legal : ContractWorks, Conga Contracts, Visual Compliance
  • Advertising/Social : PMG, Facebook Advertising, Linked Advertising, Google AdWords, Sprout Social, Tweetdeck, EventBrite, Youtube, Moz Pro
  • Marketing : MailChimp, mailgun, Mandrill, Meetup, Disqus, Google Analytics, Google Tag Manager, Cookiebot, shopify, about.gitlab, Zapier, Marketo, Demandbase, Drift, PathFactory, Bizzabo, FunnelCake, Bizible, Enrichment TBD, LeanData, WebEx, Outreach, Point of Reference
  • Prospecting & Enrichment : DiscoverOrg, DataFox, LinkedIn Sales Nav, GovWin(PubSec), Lusha (EMEA)
  • Meeting Setting Vendors : Dogood, BAO (By Appointment Only)

Troubleshooting

502 error

This may be caused by Unicorn, which acts as the gateway, not working properly. If you check the log file, you can see an error message like the one below. For reference, the log file is at ./var/log/gitlab/nginx/gitlab_error.log.

2015/04/08 18:55:26 [error] 32263#0: 
*1 connect() to unix:/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket failed
(111: Connection refused) while connecting to upstream, 
client: [CLIENT_IPADDRESS],
server: [HOSTNAME], request: "GET / HTTP/1.1", 
upstream: "http://unix:/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket:/", host: [HOSTNAME]

Note that on a single-core server it may take up to a minute to restart Unicorn and Sidekiq. Your GitLab instance will give a 502 error until Unicorn is up again. It is also possible to start, stop or restart individual components.

$ sudo gitlab-ctl restart sidekiq

Unicorn supports zero-downtime reloads. These can be triggered as follows:

$ sudo gitlab-ctl hup unicorn

Note that you cannot use a Unicorn reload to update the Ruby runtime.

Or check the posts below:

413 Request Entity Too Large

The following error may occur on git push.

$ git push gitlab
Counting objects: 8549, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (6388/6388), done.
error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large
fatal: The remote end hung up unexpectedly
Writing objects: 100% (8549/8549), 69.59 MiB | 136.81 MiB/s, done.
Total 8549 (delta 1833), reused 8549 (delta 1833)
fatal: The remote end hung up unexpectedly
Everything up-to-date

Edit the /etc/gitlab/gitlab.rb file as below.

nginx['client_max_body_size'] = '1024m'

If a Proxy server sits at the Front-end, you also need to change the maximum client Body size on that server.

SSL Verification error

Just add the certificate to the /opt/gitlab/embedded/ssl/certs/cacert.pem file.

HTTP 413 curl 22 The requested URL returned error

If you use a Reverseproxy, you must also change that that server.

gitlab.rb before increasing the max attachment size:

nginx['client_max_body_size'] = "200m"

Or limit the POST buffer size the client can upload.

git config http.postBuffer 524288000

For reference, if you use nginx as a reverse proxy, you need to change the following value.

server {
   // ....
   client_max_body_size 500m;
}

Server responded with 0 code

The error above can occur when uploading a file in gitlab-wiki. If checking the server logs or network status shows that no particular request was made, check the browser console. There is a good chance the following error was printed.

<span style="color: red">Blocked loading mixed active content “http://git.your.com/api/v4/projects/51/wikis/attachments”

You can check the warning above in detail on the MDN site. If you look closely, you can see a call to http from an https site.

Changing http to https in the external_url value of the configuration file will do.

However, if you configured external access as https and the inside as http with a proxy such as traefik, set it as follows.

# external_url 'GENERATED_EXTERNAL_URL'
external_url 'https://your_externarl_url'

nginx['listen_port'] = 80
nginx['listen_https'] = false
nginx['proxy_set_headers'] = {
  "X-Forwarded-Proto" => "https",
  "X-Forwarded-Ssl" => "on"
}

For reference, for me it worked fine even without setting the nginx['proxy_set_headers'] part.

After finishing the configuration, restart the container or use the following command.

sudo gitlab-ctl reconfigure

List of Issue Tracking System

See also

Favorite site

Documentation

Install

CI

Articles

References


  1. See OpenSSL for how to create one. ↩

  2. Ubuntu_on_GitLabHQ.pdf ↩

  3. Gitlab5_install.pdf ↩

author Zer0 sitemap