Part 5 - Configuring Git Server (GitLab)

This is the fifth post in the series of how to host your own git server on a Raspberry Pi

You have successfully installed GitLab in the previous post. We are going to look into further configuration options and set up runners to enable continuous integration (CI) for our projects.

1. Disable Usage Statistics (Optional)

One of the main benefits of self-hosting your git server is that you have full control over your data. In this direction, you can further limit GitLab to collect information about your usage.

From Admin Area (wrench icon by the menu), go to Settings > Metrics and profiling and disable usage ping and version check.

Usage Statistics Setting

2. Disable Third Party Offers (Optional)

GitLab also comes with third party offers (promotional materials & ads) enabled out of the box, so turning this off could be good for your sanity.

You can go to Settings > General and disable Third party offers.

Third Party Offers Setting

3. Disable Self-Monitoring Project (Optional)

You will also notice that GitLab comes with a monitoring project out of the box. This is a system created project, and can be controlled through the setting in (how to access)

Self Monitoring Setting

I recommend turning monitoring project off, as we will be monitoring gitlab through other means.

4. Change Default Branch Name (Optional)

You can follow the recent trend in large tech companies and rename the default branch name from Settings > Repository to main.

Default Branch Name Setting

Because Black Lives Matter too…

5. Create GitLab User Accounts

Once you go through the configurations, the next step is to create accounts for your users. You can access the sign-up page by visiting http://<gitlab-link>/users/sign_up

User Registration Screen

Fill in the details and click Register. GitLab will send a confirmation mail to the email address specified:

User Confirmation Email

Do this step for every user you want to create.

6. Record Runner Configuration

To use the Continuous Integration (CI) features of GitLab, you need to install and configure runners. Runners are externally run processes that help the CI system to build and deploy your projects automatically.

GitLab provides default configurations to set these runners manually. Log into GitLab with an Admin Account and go to Overview > Runners to see these configurations.

Record the Coordinator URL <coordinator-url> and CI Token <ci-token> for this setup.

7. Install GitLab Runners

Execute the following script to install the necessary dependencies and add package repositories for GitLab provided Runners.

curl -L | sudo bash

You can then install the runners with the following script:

sudo apt install -y gitlab-runner

8. Register GitLab Runners

Next step is to connect your runners to GitLab:

sudo gitlab-runner register

Provide responses to the questions in the registration process:

Please enter the gitlab-ci coordinator URL (e.g.
Please enter the gitlab-ci token for this runner:
Please enter the gitlab-ci description for this runner:
Please enter the gitlab-ci tags for this runner (comma separated):
Please enter the executor:
Runner registered successfully.

Provide the <coordinator-url> and <ci-token> from the values you have recorded previously. Then enter a description and a tag for this runner. When asked for the executor, enter shell.

9. Configure GitLab Runners

Now that your runner is registered, it should show up under Overview > Runners

Clicking the Edit button (Pen) will bring up the settings page for this runner. Configure the runner with following settings. You can also update the Description and Tags on this page.

Active - Checked
Protected - Unchecked
Run untagged jobs - Checked
Lock to current Projects - Unchecked

9. Adjust Runner Access

The GitLab runner setup script has created a user called gitlab-runner on your Raspberry Pi. GitLab will execute tasks using the shell interface of this user.

For Runners to successfully operate, they should have super user access to perform various commands. You can add gitlab-runner user to sudo users group with following:

sudo adduser gitlab-runner sudo

Since there is not an actual user to enter a password behind this user account, make sure the Raspberry Pi will not ask for passwords when running sudo from this Runner:

echo ‘gitlab-runner ALL=(ALL) NOPASSWD: ALL’ | sudo tee /etc/sudoers.d/010_gitlab-runner-nopass wd

Congratulations — You have successfully configured your git server! Next post is going to talk about setting up a reverse proxy (Nginx) and serving static web pages.

Systems Engineer, specialized in building Internet of Things (IoT) devices and applications. Harvesting crops at Google. 💻

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store