Complete Guide To Setting Up GitLab Locally On Mac..!!

In the last article, we saw the various parts of GitLab, its architecture and how GitLab works. If you haven’t already, I suggest reading the previous article first before reading this one. Here is the link

GitLab, A Complete Beginner’s Guide!

In this article lets look at how to set it up locally on your Mac, so that you can have your very own GitLab setup running right at your home or organization!

If you are using Windows or Linux, you can follow the links below.

Complete Guide To Setting Up GitLab Locally On Windows PC..!!

Complete Guide To Setting Up GitLab Locally On Linux PC..!!

So let’s begin!

Things you will need

All you need are a computer running Mac OS with enough resources (CPU, memory, and disk space) for running the GitLab Server and GitLab Runner. How much resources is enough depends on how much performance you need, but I was able to run it on a 2015 MacBook Air with a Core i5 and 4GB of RAM.

You can also set it up on the cloud over at, but

  • the free plans have some limitations in terms of processing power and hard disk space.
  • Also doing it locally gives you more control over the setup and
  • it will also be an opportunity to learn you more about GitLab

Hence I suggest taking this route of a local installation.

If you are part of a larger organization, and you wish to install it on the cloud, then you can always take a look at the paid plans of GitLab here link

Approach to install GitLab on Mac

Okay, let’s get back to the task in hand.

As we saw in the previous article GitLab consists of 2 parts.

  1. GitLab Server and
  2. GitLab Runner

Also, we have learned in the previous article that it is preferable to set the GitLab server and runners on separate computers. But I am going for a home set up, so I will be setting them both upon the same Mac computer.

The GitLab Server relies heavily on Linux technologies and hence it cannot be installed in our Macs natively. There are some workarounds that you can try though, like the method presented in this link

The problem with these workarounds are

  1. The installation process is a bit complicated and is not recommended for beginners.
  2. They are only guaranteed to work on a version to version basis. What I mean by that is you need to have a particular version of Mac OS and a particular version of GitLab for everything to run smoothly. If you update your Mac or if you wish to upgrade your GitLab then you might break your GtiLab set up. Since both Mac OS and GitLab updates come frequently, it is not such a good idea to waste time trying to fix things every few months.
  3. It is unofficial and hence support for future versions cannot be guaranteed.
  4. These unofficial methods will bring their own limitations as opposed to running natively on Linux

Due to these above reasons, we are going to go for a more stable approach of installing the GitLab server in a virtual environment. We will also see in this article the ways to make it run as smoothly and efficiently as possible while making sure it consumes as few resources as possible.

So this is what we are going to do

  1. Install the GitLab Server on a Virtual Box running Ubuntu server
  2. Install GitLab runner natively on Mac OS.

This approach takes away the cons of using unofficial hacks, as it will work on all versions of you Mac OS and GitLab and you don’t need to worry too much while updating your software either!

By following the step by step guide shown below you should be able to set everything up and running in an hour or 2 (depending upon how good your internet connection is, it can take longer!)

GitLab Installation Process

STEP#1: Download and install VirtualBox

You can download and install VirtualBox from this link

Download VirtualBox 
Here you will find links to VirtualBox binaries and it 
VirtualBox binaries 
By downloading, you agree to the terms and condit 
If you're looking for the latest VirtualBox 5.2 packa 
6.0. Version 5.2 will remain supported until July 20

Just click on the OSX hosts and the download should start automatically. The installation process is pretty straightforward, you can just accept the default options and click through to complete the process.

Once the installation is completed you can open VirtualBox just like any other app on your Mac from the launchpad

STEP#2: Install Ubuntu Server as a Virtual Machine in your Mac.

The next step is to get a Linux distro to install our GitLab server. For this purpose, I recommend Ubuntu Server. I chose this particular distro for 2 reasons.

  1. Ubuntu is known for its stability.
  2. GitLab Server software has support for Ubuntu
  3. The server edition is chosen so that it will consume fewer resources on your computer.

For this first, you need the Ubuntu Server image. You can download it from this link.

Ubuntu usually offers 2 sets of packages for us to choose from.

  1. Long term support version: Has a support period of 5 years
  2. Latest Version: has all the latest features.
Download Ubuntu Server 
Ubuntu Server 18.04.3 CTS 
The long-term support version of Ubuntu Server, including the Train release of OpenStack 
and support guaranteed until April 2023 — 64-bit only. 
This release uses our new installer, Subiquity. If you need support for options not 
implemented in Subiquity, such as encrypted filesystem support, the traditional installer 
can be found on the alternative downloads page. 
Ubuntu Server 18.04 LTS release notes 
Ubuntu Server 19.10 
The latest version of Ubuntu Server, including nine months of security and maintenance 
For other versu 
the network in! 
past releases

I suggest you go for the LTS one, but then the latest version should also work just fine. So click on a “Download” button and your download should start automatically. It will take some time to complete as the iso is around 900MB.

Once the download is complete you can proceed to the installation process on VirtualBox.

STEP#3: Install Ubuntu Server on VirtualBox

Open VirtualBox from your Applications folder by double-clicking it.

Oracle VM VirtualBox Manager 
preferences : Import Export 
Welcome to VirtualBox! 
The left part of application window contains global tools and lists all virtual machine 
and virtual machine groups on your computer. You can import, add and create new 
using corresponding toolbar buttons. You can popup a tools of currently selected 
element using corresponding element button. 
You can press the X? key to get instant help, or visit for more 
information and latest news.

Next click on the new button and a window like this should pop up

Name and operating system 
Please choose a descriptive name and destination 
virtual machine and select the type of operating sys 
install on it. The name you choose will be used throL 
identify this machine. 
Machine Folder: 
Ubuntu Served 
Ubuntu (64-bit)

Give your virtual machine a name and choose Linux for type and ubuntu 64 bit for version and click “Continue”.

The next screen usually asks for RAM. GitLab recommends 8GB for a GitLab system with 100 users,  I suggest a minimum of 2GB RAM for a home set up, you can give more if you can, just make sure you don’t allot more than 50% of your total available RAM.

Memory size 
Select the amount of memory (RAM) in megabytes t 
the virtual machine. 
The recommended memory size is 1024 MB. 

Once you have allocated RAM space, Click “Continue” to the next page.

Hard disk 
If you wish you can add a virtual hard disk to the ne' 
either create a new hard disk file or select one from 
another location using the folder icon. 
If you need a more complex storage set-up you can 
make the changes to the machine settings once the 
The recommended size of the hard disk is 10,00 GE 
Do not add a virtual hard disk 
O Create a virtual hard disk now 
Use an existing virtual hard disk file

Next, you will be prompted for hard disk. Make sure “Create a virtual hard disk now” is selected and click “Create”

Hard disk file type 
Please choose the type of file that you would like to u 
hard disk. If you do not need to use it with other 
can leave this setting unchanged. 
O VDI (VirtualBox Disk Image) 
VHD (Virtual Hard Disk) 
VMDK (Virtual Machine Disk)

Accept the default “VDI (VirtualBox Disk Image)” and click “Continue”

Storage on physical hard disk 
Please choose whether the new virtual hard disk file s 
used (dynamically allocated) or if it should be created 
(fixed size). 
A dynamically allocated hard disk file will only use 
hard disk as it fills up (up to a maximum fixed size), a 
shrink again automatically when space on it is freed. 
A fixed size hard disk file may take longer to create c 
is often faster to use. 
O Dynamically allocated 
Fixed size

Accept “Dynamically Allocated” and Press continue. This option allocates hard disk space to the virtual machine on the run, so that as you use the more space, more will be allocated.

File location and size 
Please type the name of the new virtual hard disk file 
click on the folder icon to select a different folder to c 
/Users/EmbeddedlnventorNirtualBox VMs/Ubuntu Sel 
Select the size of the virtual hard disk in megabytes. 
on the amount of file data that a virtual machine will b 
hard disk. 
4,00 MB 

I suggest you allocate at least 25GB of space to the virtual machine, you can allocate more if you can. Once you have chosen the disk space click create

Once you have done this, you should be taken back to the main window of VirtualBox and you should see the virtual machine you just created on the left pane of the window as shown in the screenshot below.

Ubuntu Server 
Powered Off 
New Settings 
Oracle VM VirtualBox Manager 
Ubuntu Server 
erating System: Ubuntu (64-bit) 
Base Memory: 2048 MB 
Boot Order: Floppy, Optical, Hard Disk 
Acceleration: VT-x/AMD-V, Nested Paging, KVM Paravirtualization 
[S Display 
Video Memory: 
Graphics Controller: 
Remote Desktop Server: 
Controller: IDE 
IDE Secondary Master: 
Controller: SATA 
SATA Port O: 
16 MB 
[Optical Drive] Empty 
Ubuntu Server.vdi (Normal, 25,00 GB)

Next click on the “Settings”

Ubuntu Server 
Powered Off 
New Settings 
Oracle VM VirtualBox Manager 
Ubuntu Server 
Operating System: Ubuntu (64-bit) 
Base Memory: 2048 MB 
Boot Order: Floppy, Optical, Hard Disk 
Acceleration: VT-x/AMD-V, Nested Paging, KVM Paravirtualization 
Video Memory: 
Graphics Controller: 
Remote Desktop Server: 
Controller: IDE 
IDE Secondary Master: 
Controller: SATA 
SATA Port O: 
16 MB 
(Optical Drive] Empty 
Ubuntu Server.vdi (Normal, 25,00 GB)

And click on storage -> empty -> disk icon -> “Choose/Choose a disk file”

Ubuntu Server - Storage 
General System 
Storage Devices 
O Empty 
n o er: 
Network Ports 
Shared Folders 
user Interface 
Optical Drive: 
Attached to: 
IDE Secondary Master 
Live CD/DVD 
Ubuntu Server.vdi 
Choose a disk 
Remove Disk

Select the ubuntu server iso image you have just downloaded and press ok. This is equivalent to inserting the Ubuntu disk in a real machine.

Ubuntu Server - Network 
Display Storage Audio Network 
Adapter 1 
Adapter 2 
Enable Network Ada ter 
Ports Shared Folders user Ir 
Adapter 3 Adapter 4 
Attached to: 
Bridged Adapter 
enO: Wi-Fi (AirPort)

Next, go to settings->Network and choose “Bridged Adapter” in the “Attached to:” drop-down menu and press “OK”

I have explained the reason behind using these network settings in detail in this article, you can go ahead and read that if you are into computer networks.

The short explanation is, we will not be able to access the GitLab server from our other machines on the network unless we choose this option.

That’s it, the configuration is done!

You can now go ahead and click the start button!

Ubuntu Server 
Powered Off 
New Settings 
Oracle VM VirtualBox Manager 
Ubuntu Server 
Operating System: Ubuntu (64-bit) 
Base Memory: 2048 MB 
Boot Order: Floppy, Optical, Hard Disk 
Acceleration: VT-x/AMD-V, Nested Paging, KVM Paravirtualization 
[S Display 
Video Memory: 
Graphics Controller: 
16 MB 
Remote Desktop Server: Disabled 
Controller: IDE 
IDE Secondary Master: [Optical Drive] ubuntu-18.04.3-live-server-amd64.iso (84t 
Controller: SATA 
SATA Port O: 
Ubuntu Server.vdi (Normal, 25,00 GB)

Now the installation process will start. Since we have chosen to go with “Ubuntu server” in order to minimize the resource consumption (so that GitLab can take up as many resources as it needs) we don’t get a fancy Graphical UI, like in the desktop version of Ubuntu. You need to navigate the menus during installation only using Keyboard (tab, enter and arrow keys) since the Ubuntu server doesn’t come with mouse support. So go through the process and get it done.

STEP#4: Get the IP address of your ubuntu server

Okay now once you got the Ubuntu server up and running, you need to find its IP address and make a note of it.

To do that, use the “ifconfig” command on your Ubuntu server’s terminal

' $ ifconfig 
LIP mtu 1500 
netmask broadcast 
pref ixlen 64 scopeid 
ether txqueuelen 1000 (Ethernet) 
RX packets 13 bytes 1840 (1.8 KB) 
RX errors 0 dropped 0 overruns O frame O 
TX packets 14 bytes 1600 (1.6 KB) 
TX errors O dropped O overruns O carrier O 
, 65536 
inet netmask 
: : 1 pref ixlen 128 scopeid 
loop txqueue len 1000 (Local Loopback) 
RX packets O bytes O (0.0 B) 
RX errors 0 dropped 0 overruns O frame O 
TX packets O bytes O (0.0 8) 
TX errors O dropped O overruns O carrier O 
collisions O 
collisions O

STEP#5: Connect to the VM through SSH.

The next step is to connect to the ubuntu server from your Mac OS’s terminal. This will make the process of talking to your VM easier as it will ease the process of entering commands and use the various features offered by the Mac OS user-friendly terminal.

You can use the IP address of the Ubuntu server that you have just noted down to connect to your VM from your Mac’s terminal using the command

ssh ei@

Don’t forget to replace the username and IP with your own!

ssh <username>@<IP address>

Enter your password when prompted, then you can log in to your VM from your Mac OS’s terminal.

If you are able to log into the VM, that means you have successfully set up the base needed to build the GitLab system on top of it!

Memorize or make a note of the command above as you will need to enter it every time you need to make some changes to your GitLab server!

This step is optional, as you can always type on the ubuntu server’s command prompt and start it up whenever you want it to,  but I recommend doing that for convenience purposes!

The next step is to install the GitLab server, so let’s go ahead and do that next!

STEP#6: Download and install GitLab server

To download GitLab server, go to the official link on the Gitlab’s Website

Download a GitLab Omnibus package (recommended install 
16.04 LTS, 18.04 LTS 
Centos 7 
8, 9, 10 
OpenSUSE Leap 15.1 
Centos 6 
and RHEL, Oracle, Sci 
Raspberry Pi

As you can see GitLab official supports several Linux distros, even a Raspberry Pi 2’s Raspbian! We are interested in Ubuntu, so click on the Omnibus Ubuntu Link on as shown in the screenshot above.

Once you click on Ubuntu,  the commands you need to enter to install GitLab server will be shown to you.

I am not showing each instruction here since GitLab updates the information presented on their website all the time and that can make this section of the article outdated. Just follow the step by step instructions given in the link to install the GitLab Server on your VM.

1. Install and configure the necessary dependencies 
sudo apt—get update 
sudo apt—get install —y curl openssh—server ca—certificates 
Next, install Postfix to send notification emails. If you want to use another solution to send emails please skip this step 
an external SMTP server after GitLab has been installed. 
sudo apt—get install —y postfix 
During Postfix installation a configuration screen may appear. Select 'Internet Site' and press enter. Use your server's e 
'mail name' and press enter. If additional screens appear, continue to press enter to accept the defaults. 
2. Add the GitLab package repository and install the package 
Add the GitLab package repository.

You can do this either on your Mac OS’s terminal after logging into your VM through SSH as shown in step 5 or you can simply type them on your VM’s command prompt directly. If you are using the Mac Terminal you can use the clipboard icon shown in the screenshot above to easily copy and paste the commands!

A couple of tips on the GitLab installation instructions


In the postfix installation step (step 1 last command on the GitLab website)

sudo apt-get install -y postfix

 you can skip the mail option by choosing the “no configuration” option as shown in the screenshot below.

r—.l postfix Configuration 
Please select the mail server configuration type that best meets 
No configuration: 
Should be chosen to leave the current configuration unchanged. 
Internet site: 
Mail is sent and received directly using SMTP. 
Internet with smarthost: 
Mail is received directly using SMTP or by running a utility 
as fetchmail. Outgoing mail is sent using a smarthost. 
Satellite system: 
All mail is sent to another machine, called a 'smarthost' , 
Local only: 
The only delivered mail is the mail for local users. There is 
General type of mail configuration: 
No configuration 
Internet Site 
Internet with smarthost 
Satellite system


In the last command of step 2 at GitLab website

sudo EXTERNAL_URL="" apt-get install gitlab-ee

Make sure you replace the URL with the IP address of the VM that we have made a note of in Step 5 above like this

sudo EXTERNAL_URL= apt-get install gitlab-ee

Or to be more precise just place the VM’s IP address that we obtained in Step#4 in its appropriate place

sudo EXTERNAL_URL=”<Your VM’s IP address>” apt-get install gitlab-ee

This step will take a while, so be patient. In my machine it took 8 minutes 24 seconds as shown in the screenshot below, yours can vary depending on the processing power it has.

Once done it will show u something like in the screenshot below.

Chef Client finished, 
gitlab Reconfigured ! 
549 / 1489 resources updated in 08 minutes 24 seconds

Once it’s done, you can go ahead to your favorite browser and type in the IP address of your VM and check if the installation has succeeded. 
Please create a password for your new account. 
GitLab Enterprise Edition 
Open source software to collaborate on code 
Manage Git repositories with fine-grained access controls that keep your 
code secure. Perform code reviews and enhance collaboration with 
merge requests. Each project can also have an issue tracker and a wiki. 
Change your password 
New password 
Confirm new password 
Change your password 
Didn't receive a confirmation email? Request a ru 
Already have login and password? Sigr

And voila! GitLab server installation has succeeded!

Go ahead and follow the onscreen instructions to set up your password, accounts and everything else!

STEP#7: Download GitLab runners

Now that we have set up the Gitlab server, the next step is to set up the GitLab runner!

For this, I am gonna ask you to follow the commands given in the GitLab website again for the sake of getting the most up to date instruction.

Manual installation (official) 
O Note: For documentation on GitLab Runner 9 and earlier, visit this documentation. 
Download the binary for your system: 
sudo curt —output /usr/locat/bin/gitlab—runner https://gitlab—runner—downl 
You can download a binary for every available version as described in Bleeding Edge - dl 
Give it permissions to execute: 
sudo chmod +x /usr/tocat/bin/gitlab—runner 
The rest of commands execute as the user who will run the Runner. 
1. Register the Runner 
ns a e unner as service an 
s ar

I recommend you to follow the “manual installation” method shown in the screenshot above and not the “homebrew” one since the manual method is the official one. Also for Downloading the GitLab runner, you just need the first 2 out of 4 steps (rectangles 1 and 2) as shown in the screenshot above.

Step#7.1 Download the GitLab runner binary

Step#7.2 Give it permissions to run/execute

These 2 steps are fairly simple, you just need to copy-paste the commands into your Mac’s terminal.

$ sudo curl 
—output /usr/local/bin/gitlab—runner https://gitlab—rur 
Password : 
% Total 
100 36.4M 
Received % Xferd 
36 .4M 
Average Speed 
Dload Upload 

You will get something similar to what’s shown in the screenshot above.

Now that we have GitLab runner installed, the next step is to connect the GitLab runner and the GitLab server.

STEP#8: Connect the GitLab server to the GitLab runner

GitLab calls this process of connecting the Server to Runner as “Registering the GitLab Runner to the Server”

You can follow the instructions for Mac OS in this link to do the same.

Step# 8.1: Start the registration process

Register by entering the below command on your Mac’s terminal

gitlab-runner register

Once you enter this command, you will be prompted to enter the URL of your GitLab server, which is basically the IP address of your Ubuntu Server Virtual Machine.

Run the following command: 
git tab—runner register 
Enter your GitLab instance URL: 
Please enter the gitlab—ci coordinator URL (e.g. 
https : //gittab. com 
Enter the token you obtained to register the Runner: 
Enter the IP addre ) 
Please enter the gitlab—ci token for this runner 
Enter a description for the Runner, you can change this later in GitLab's UI: 
Please enter the gitlab—ci description for this runner 
[hostname] my—runner 
Enter the tags associated with the Runner, you can change this later in GitLab's UI:
$ gitlab—runner register 
Running in user—mode. 
Use sudo for system—mode: 
$ sudo gitlab—runner... 
arch=amd64 os=darwin pid=4466 revisi

As shown in the screenshots above, enter your Virtual Machine’s  IP address when prompted. Make sure you add “http://” before the IP address.

Once the IP address is entered, the next prompt appears asking you to enter a token, so let’s first go get a token from our GitLab server.

Step#8.2: Obtain token from GitLab Server

Go to your browser and enter the GitLab Server’s IP address. Once you have logged in you can create your first project by clicking on the respective pane as shown in the screenshot below.

O GitLab 
Projects v 
Groups v 
More v 
Create a project 
Welcome to GitLab 
Faster releases. Better code. Less pain. 
Projects are where you store your code, access issues, 
wiki and other features of GitLab. 
Click here 
Explore public projects 
Search or jump to... 
Create a group 
Groups are the best way to mar 
Learn more about GitLal

Just give the project a name and click on the create project button. The other field should get populated automatically.

Blank project 
Pro•ect name 
Test Project 
Project URL 
Create from template 
Project slug 
want to house several dependent projects under the same namespace? Create a group. 
Project description (optional) 
Description format 
Visibility Level O 
o Private 
Project access must be granted explicitly to each user. 
The project can be accessed by any logged in user.

Once you click the button as shown in the screenshot above, you will be taken to your project page.

From there just click on Settings->CI/CD and scroll down a bit and you will find the token you need as shown in the screenshot below.

T Test Project 
Project overview 
O) Issues 
I h Merge Requests 
•e CI/CD 
X Snippets 
Specific Runners 
Set up a specific Runner automatically 
you can easily install a Runner on a Kubernetes cluster. 
Learn more about Kubernetes 
1. Click the button below to begin the install process 
by navigating to the Kubernetes page 
Select an existing Kubernetes cluster or create a 
new one 
From the Kubernetes cluster details view, install 
Runner from the applications list 
Install Runner on Kubemetes 
Set up a specific Runner manually 
I. Install GitLab Runner 
2. specify the following URL during the Runner setup: 
http: // tö 
Shared Runne 
GitLab Shared Runni 
on the same Runner 
Autoscale with MaxE 
Disable shared Rur 
This GitLab instance dc 
Instance administrators 
admin area. 
Group Runner 
GitLab Group Runne 
projects in this groug 
Runners API.

This token basically connects your project on the GitLab Server to the GitLab runner.

Step#8.3: Enter the token

Now that we have the token let’s enter it on the Mac OS terminal

Please enter the it lab—ci 
token for this runner: 
TzVSVczCCii3d2zMXMPd 1 
or this run 
. test roject 2 
Please enter the gitlab—ci 
tags for th1S runner (co

Once entering the token, you will be prompted to give the runner a description, go ahead and do that.

After that, you will be asked to enter some tags.

What are tags? Why are they needed for GitLab runners?

The better term for tags can be capabilities.

Consider this scenario.

Assume you are working in a large team of 1000 developers, who are doing say 50 different projects and your GitLab system has 100 different runners set up with several capabilities to do specific tasks. Some projects may need C compilers, while others may need python interpreters.

Now in order to connect a given project with a free-runner, we need some sort of parameter to tell the GitLab server that this particular free runner is capable of running the scripts needed for that particular job.

This is where tags come into the picture. By giving tags like “C” or “Python” a single runner can be connected to multiple projects and a single project can execute its jobs on several runners to ensure the best possible performance.

Using these tags the Gitlab server can find a runner with the specific capability to use for a given job. So give some suitable tags that will imply the capabilities of your runner.

Once that is done, you will be prompted to enter “executor”.

Executors are programs that run our CI/CD scripts. Type shell and press enter

Please enter the executor: docker+machine, docker—ssh+machine, docker—ssh, parallels, shell, virtu 

This will end the registration process the Runner to the server

Once registered you can start the GitLab runner as a Service (background task) by issuing the commands

gitlab-runner install
gitlab-runner start

Restart your Mac, log into your account and your runner should be ready to go!


The screenshot above is taken from the activity manager app and as you can see we have an entry for GitLab-runner!

Test to see if everything works

By following the 8 steps above, you should have a set up with GitLab Server and Runner running on your system. Its time to test and see if everything works the way it is supposed to work!

First, let’s test the GitLab server by creating a repo and pushing it to the server.

Testing GitLab Server

STEP#1: Make a test git repo

Let’s make a simple git repo on a new folder on our Desktop and push it to the GitLab server.

So go over to your terminal and type in the following commands

cd Desktop
mkdir test_project
cd test_project
touch test.c

The above lines of command are just the fancy way of creating a folder named test_project on your Desktop and a file named test.c inside it. You can also do it through the Graphical User Interface if you want to.

So next, please open the C file using your favorite text editor and type in a simple program for testing, something like the following.

#include <stdio.h>

int main()
	printf("Hello Embedded Inventors!");
	return 0;

Next, let’s initialize a git repository on our test_project folder. So go back to the terminal  cd into the test_project folder and type in the following command

git init

If git is not already installed you will get a pop-up window asking if you wish to install the X-Code developer tool. Click install and Mac OS should automatically download and install the necessary tools for you. If a pop up doesn’t come, then just go to App Store on your Mac and install the X-code app by Apple.

Once the installation completes, try entering the command again

git init

You should receive a reply saying “Initialized empty Git repository”

Then add our test.c file and commit the changes using the following commands

git add .
git commit -m"first commit"

STEP#2: Push it to the server

Now that we have our git repo ready, let’s push it to our git server. To do that login to your GitLab and go to the project we created earlier. There GitLab shows us the commands needed to push our repo to the server.

First, let’s configure our name and email on the git repository to the ones set on the GitLab server

So enter the following command.

git config --global "<enter your name here>"
git config --global "<enter your email here>"

Next, we need to connect our server and our repository. To do that just enter the following commands

git remote add origin <your project URL>.git

In my case it is

git remote add origin 

To find your project URL, just copy the address bar of your browser while you are on your project’s page in GitLab

Then push your git repo onto the GitLab using the command

git push -u origin master

Once done, just refresh the page and you should be able to see your test project page in GitLab!

Test Project a 
Project ID: I 
1 Commit p 1 Branch O O Tags 
133 KB Files 
test-project / 
Q Fil 
first commit 
authored 24 minutes ago 
Auto Devops enabled : @ Add README 
@ Add Kubernetes cluster 

Testing GitLab Runner

STEP#3: Make a simple bash script to build the test.c file

Create a bash script on your project folder

cd Desktop/test_project

Edit it so that it looks something like this

gcc test.c -o test
echo "Build completed"

STEP#4: Create and edit .gitlab_ci.yml to run the above script

What is .gitlab-ci.yml and why it is needed? This is the file that contains the instructions for the GitLab runners to execute the CI/CD tasks. It should be present in the project’s root folder. It can be used to test if a commit builds correctly, passes some unit tests and if it needs packaging and deployment.

You can learn more about how to configure it from the official quick start tutorial here

For the purpose of testing our installation let’s create a file named .gitlab-ci.yml in the test_project folder and put the following lines in there.

Make sure you are in the right directory

cd Desktop/test_project

Create the file using the command

touch .gitalb-ci.yml

Open it with your favorite text editor and type the following lines into it.

    - bash
  tags: [test]

The last line tells the GitLab server to use the GitLab runner with the tag named “test”. If you gave your GitLab runner installation a different tag, make sure you make the appropriate change to the above lines.

Also, make sure you use spaces instead of tabs at the beginning of the above lines.

Now add it to the git repository and push it to the Gitlab server

git add .
git commit -m"gitlab yml added"
git push

Now let’s get back to our GitLab server’s URL and see if it worked. Go to the project page and click on CI/CD

T Test Project 
Project overview 
Cycle Analytics 
O) Issues 
Merge Requests 
e Cl / CD 

You will be taken to the pipeline page which shows the result of your latest commit.

@ passed 
Pmaster bb227bø1 

It will take a minute or so before it completes the pipeline and as you can see in the screenshot above, mine took 41 seconds to complete and the status is “passed”

If you click on “jobs” under the CI/CD menu, you will be taken to another page which shows you more information about the execution of our yml file

O) Issues 
I h Merge Requests 
re CI/CD 
@ passed 
#5 Y master o- bb227bØ1 
#38 by O 

Next click on “passed” as shown in the screenshot above, this will take you to another page which will look something like this

T Test Project 
Test Project Jobs #5 
Job #5 triggered 22 minutes ago by 
@ passed 
Project overview 
Merge Requests 
Running with gittab—runner 12.6.ø (ac8e767a) 
on test project VaQ2xpuE 
Using Shetl executor. 
Fetching changes with git depth set to 50... 
Initialized empty Git repository 
Created fresh repository. 
From http://192.168.e.115/E1/test-project 
* (new ref) 
* [new branchl 
refs/pipeUnes/38 —s refs/pipe1ines/38 
Checking out bb227bø1 as master... 
Skipping Git submodules setup 
$ bash 
Build completed 
Job succeeded

As you can see, our gets executed by the GitLab runner and it succeeds to compile our project.

And with that, I will conclude this tutorial!

I leave the rest to you to play, explore, experiment and learn GitLab!

I hope you guys enjoyed this article and learned something useful. 

You can email us or contact us through this link if you have any questions or suggestions.

If you liked the post, feel free to share this post with your friends and colleagues!

Photo of author
Balaji Gunasekaran
Balaji Gunasekaran is a Senior Software Engineer with a Master of Science degree in Mechatronics and a bachelor’s degree in Electrical and Electronics Engineering. He loves to write about tech and has written more than 300 articles. He has also published the book “Cracking the Embedded Software Engineering Interview”. You can follow him on LinkedIn