+3 votes
157 views
in Web development by (242k points)
reopened
GitLab tutorial: installation and first steps

1 Answer

+4 votes
by (1.6m points)
edited
 
Best answer

How does GitLab work?
GitLab Features Overview
GitLab Licensing and Usage Models
GitLab installation: how to do it
First steps
GitLab on your own server or in the cloud
GitLab installation on Linux server
Installation on Windows
User creation
Create a new project
GitLab: teamwork tutorial

image

GitLab tutorial: installation and first steps

GitLab is a popular version control system (VCS) that is mostly used in software development. In 2011, Dimitri Saparoschez wrote and published this web-based software in the Ruby on Rails language. Today, it has become a must-have for developers..

The main advantage of GitLab is that it greatly facilitates agile software development across multiple teams . In this way, several developers can work simultaneously on a project and edit, for example, different functions in parallel. The notarization continuous of all processes ensures that no modifications or lose the code being overwritten unintentionally. It is also possible to quickly undo the changes already applied.

GitLab is based on the commonly used version management software Git. Git is available for free as open source software and is considered one of the most widely used version control systems in general. GitLab is one of the most popular GitHub alternatives (when Microsoft got GitHub in 2018, many users switched to GitLab)..

Index
  1. How does GitLab work?
  2. GitLab Features Overview
  3. GitLab Licensing and Usage Models
  4. GitLab installation: how to do it
    1. GitLab on your own server or in the cloud
    2. GitLab installation on Linux server
      1. Repository update
      2. GitLab installation
    3. Installation on Windows
      1. Downloading Git for Windows and GitLab Runner Binary Data
      2. GitLab Runner log on Windows
      3. Install and start GitLab Runner on Windows
  5. First steps
    1. User creation
    2. Create a new project
    3. GitLab: teamwork tutorial

How does GitLab work?

GitLab is a web-based application with a graphical user interface that can also be installed on your own server . The core of GitLab is made up of projects in which the code to be edited is stored in digital files, the so-called repositories. In these project directories are all the contents and files of a software project, that is, JavaScript, HTML, CSS or PHP files, among others.

In this GitLab tutorial we explain how it works. To begin, everyone involved in the project downloads a copy of their own from the central repository onto their computer. From there, changes to the code are made through so-called commits . After editing, the changes are integrated into the main repository..

Another important function is branching . This allows users to create a? Branch? which branches off from the main part of the code and can be edited independently of it. This function is especially useful when introducing and testing new functions without affecting the development of the main line.

With built-in seamless delivery and integration, GitLab is perfect for branching, offering useful features like merge requests and branching. Therefore, the software is one of the most popular continuous integration tools.

GitLab Features Overview

Among the most important features of GitLab are the following:

  • Easy to use interface
  • Branches can remain private or be published
  • Possibility of managing multiple repositories
  • Code review
  • Integrated error and problem location
  • Continuous integration and continuous delivery (CI / CD) built-in for free
  • Project wikis
  • Simple creation of code snippets to divide parts of the code.

GitLab Licensing and Usage Models

GitLab is based on open source and free access code. In 2013, its own Enterprise version was created for companies, so there are now two usage models:

  • GitLab CE: Community-Edition (free)
  • GitLab EE: Enterprise-Edition (paid)

Both versions are based on the MIT open source license . The Enterprise-Edition has some additional functions compared to the Community. In this context, GitLab offers three subscription models depending on the scope of additional features desired.

The Enterprise-Edition can also be used for free, but only with the basic functions of the Community-Edition. This option is intended for cases in which later it is convenient to switch to the Enterprise variant , since all it takes is one click to make the change. The step from the Community version is much more complicated and requires more time.

GitLab installation: how to do it

As a general rule, we recommend a Linux environment to use GitLab, since like Git, GitLab is factory-built for Linux. The use in Windows implies a series of restrictions, in these cases, a virtual machine that simulates a Linux environment can be used on a Windows computer. A less complicated option is the installation of the so-called GitLab Runner which is also required to use GitLab continuous integration.

GitLab on your own server or in the cloud

Installing GitLab on your own server is not complicated for any user who knows Linux, but it does take a long time. Regardless of the installation itself, some time needs to be spent on setup and regular maintenance work.

If you want to avoid all this, you can also use GitLab as software as a service (SaaS) and install and run it on a cloud server (there are several providers). In this way you can use the software quickly and already configured, without the need for installation. As a general rule, the GitLab Runner installation is also included, so you can start immediately.

The advantage of manual installation in your own server environment is that it provides greater flexibility . Users have complete freedom in installation: they can freely decide about backups, updates or additional resources and install only what they need in their specific case. Even so, the cloud solution is very interesting, especially if the system administrator already has a lot of work.

advice

IONOS offers powerful and affordable cloud servers and virtual servers. These tools will allow you to quickly configure your own virtual infrastructure according to your preferences. The servers are compatible with all common Linux operating systems (Ubunto, Debian) and optionally with Windows.

GitLab installation on Linux server

In order to install GitLab on a Linux server, you need the Git software first . In our Git tutorial we explain how to install it on a server. Next, you need to download the GitLab-Omnibus-Package from the official GitLab website. This package contains all the necessary files and is recommended for installing GitLab.

Repository update

You then log into the server as the root user and update the repository (in this case Ubuntu) to receive all the necessary packages for GitLab. Use the following commands:

  sudo ssh root@GitLabServer sudo apt-get update  

Install the packages as follows:

  sudo apt install curl openssh-server ca-certificates postfix  

During the Postfix installation a configuration screen appears. Select the option? Internet Site ? and enter the name of the server domain that you use to send and receive emails.

GitLab installation

Next, install the Omnibus package from GitLab. To do this, you have to first add the? GitLab Package repository? with the following command.

Next, install GitLab with the apt command . This sample code installs the GitLab Community Edition (CE).

  sudo apt install GitLab-ce  

After running the command, the server downloads and installs the GitLab package automatically. After the installation is confirmed, you still have to configure the main URL with which you access the GitLab server.

Modify the GitLab.example.com URL based on the URL you are actually using. To do this, go to the / etc / GitLab directory , where the configuration is located, and edit the GitLab.rb configuration file with the standard text editor, vim.

The commands look like this:

  cd /etc/GitLab vim GitLab.rb  

In the GitLab.rb file, find line 9 (? External_url ? ) And enter the desired URL. GitLab will then start and configure the installation from that URL.

During the first boot a screen opens in which you must reset the password . Set the password for the administrator and you will jump to the login screen. To log in you can start using the standard user? Root? as we already mentioned earlier in this GitLab tutorial. These settings can be changed later in the profile settings.

Installation on Windows

GitLab itself cannot be installed on a Windows server , but you can use a so-called GitLab Runner to access an already configured installation of GitLab on a Linux server from Windows. This software installs on Windows and supports GitLab's continuous integration functionality (GitLab CI / CD). This way, the Runner can send queries and job requests to GitLab.

Downloading Git for Windows and GitLab Runner Binary Data

To install GitLab on a Windows server, you first need Git for Windows . You can download the software on the official website. Also, in this GitLab tutorial we recommend assigning an individual password for the user account if you are not going to use the standard system account.

You also need a token that allows you to access the GitLab instance from the Runner. You will find this passkey in the GitLab settings at? Settings ? ->? CI / CD ?.

Next, download the binary file ( x86 or amd64 ) for the GitLab Runner for Windows and create a folder in any directory on your system, for example C: \ GitLab-runner .

Put the file in that folder and rename it GitLab-runner.exe . Then open Windows PowerShell (or Command Prompt) with administrator rights.

GitLab Runner log on Windows

To register GitLab Runner, enter the following command on the command line:

  ./GitLab-runner.exe register  

Now, enter the URL of the GitLab installation (in this case it is an example):

In the next window, enter the token to link the Runner with the GitLab installation. You can then set your own description for the Runner . This option can also be changed later in the GitLab interface. The next window allows you to set tags . These tags are especially useful if you are going to use a Runner to edit several projects at the same time. Using tags, you can determine exactly which projects are assigned in each case.

In the last step, you must determine the so-called? Executor ?, that is, the environment in which the Runner works, for example, in a VirtualBox instance or in a Shell environment. Shell is the easiest executor to configure and the default option if you are registering a GitLab Runner for the first time in Windows.

  Please enter the executor: ssh, docker+machine, docker-ssh+machine, kubernetes, docker, parallels, virtualbox, docker-ssh, shell: shell  

Install and start GitLab Runner on Windows

To install GitLab Runner you can use the built-in system account or your own user account. Use PowerShell or Command Prompt to navigate to the directory you created earlier and enter the following commands in succession.

  cd C:\GitLab-Runner .\GitLab-runner.exe install .\GitLab-runner.exe start  

First steps

Once GitLab is installed, you can access the graphical interface through the URL determined above. To do this, you can use any browser and log in as an administrator. The username and the corresponding password can also be changed later in the administrator section.

User creation

In the admin section , you can use the option? New User? to create all the users who will work together on the corresponding GitLab projects. To do this, you must define an email address and login details for the user and assign it to the desired project.

At the same point, you can use? Edit? to modify user rights and block users or delete them completely. Note that blocking a user prevents them from logging in, but all data (eg commits) will still be available to them. Instead, the complete deletion means the disappearance of the user with all the linked information , so you should think carefully if you want to execute this function.

Create a new project

The most important step is to create a new project. To do this, select the button? New Project? and you will jump to the window to create the project. Use the field? Project Name? to enter the project name. Don't use special characters or blank spaces. In ? Visibility? you can configure the visibility, that is, which users have access to the project. You can choose between the following levels:

  • Private : Only you will have access.
  • Internal : Any user who is logged in will have access.
  • Public : Any user can access the project without having to identify themselves in any way.

Once you have chosen the settings, create the project with the button? Create project ?. Now you can connect it directly to a local Git repository. To do this, go to the project overview, select the option? HTTPS? in the name of the project and copy the commands indicated in the command line.

If you don't already have a local copy of the repository on the server, you can remedy it at this point by entering the following command:

  $ git clone https://server/namespace/project.git  

Once you have started the repository with the first push , you can consult all the information available about the repository on the project page. There you can also check the latest activities and check the commit log to see who has made changes to the code and at what time.

GitLab: teamwork tutorial

The easiest way to work with other users in a GitLab project is to grant users direct Push access to the repository . To do this, add users to a project, as explained in this GitLab tutorial, and grant them the corresponding user rights.

Users with a ? Developer? or higher can move their commits and branches to the repository without restrictions. Alternatively, so-called combination requests can also be used . With them, it is possible to control access more strictly, since the master branch is not edited directly. Instead, users create a branch , record their commits, and then make a join request to connect the branch to the master (or another branch).

In addition, users without access rights can create forks , that is, edit their own copy of the project using push commits. They can then make a join request to bring the branches back into the main project. In this way, the project owner has full control over what goes into the repository, but can allow unknown users to contribute to their project.

Note

Being an elaborate collaboration tool, GitLab has many features that facilitate team collaboration, such as project wikis or system maintenance tools.


...