How to Set Up GitLab on Windows: A Clear Step-by-Step Guide

Dimensional Data Team
11 min readMay 4, 2024

--

GitLab is a popular web-based Git repository manager that allows developers to collaborate on code, manage projects, and automate software testing and deployment. It provides a complete DevOps platform that simplifies the development process, from code creation to deployment. In this article, we will discuss how to set up GitLab on Windows, a step-by-step guide that will help developers get started with this powerful tool.

Before we dive into the installation process, it’s important to note that there are some prerequisites that need to be met. You will need a Windows machine with at least 4GB of RAM and 2 CPU cores. You will also need to have administrative privileges on the machine, as well as a GitLab account that you can use to register your GitLab Runner. Once you have met these requirements, you can proceed with the installation process.

Key Takeaways

  • GitLab is a powerful web-based Git repository manager that simplifies the development process.
  • Before installing GitLab on Windows, ensure that your machine meets the prerequisites and that you have a GitLab account.
  • The installation process involves downloading GitLab Runner, configuring it, registering it with GitLab, verifying the setup, and automating it as a service.

Prerequisites

Windows System Requirements

Before setting up GitLab on Windows, it is important to ensure that your system meets the minimum requirements. These requirements are necessary to ensure that GitLab runs smoothly and efficiently.

Here are the minimum system requirements for GitLab on Windows:

ComponentRequirementProcessor4 coresMemory4 GBDisk space25 GBOperating system Windows 7 or later

It is important to note that these are minimum requirements, and it is recommended to have a more powerful system for optimal performance.

Installing Necessary Software

Before installing GitLab on Windows, it is necessary to install some software that GitLab depends on. These software packages are required to ensure that GitLab runs smoothly and efficiently.

Here are the software packages that need to be installed:

  • Git for Windows: Git is a version control system that is used by GitLab. Git for Windows can be downloaded from the official website here.
  • Docker for Windows: Docker is a containerization platform that is used by GitLab. Docker for Windows can be downloaded from the official website here.
  • OpenSSH: OpenSSH is used by GitLab to securely transfer files between systems. OpenSSH can be installed using the Git for Windows installer.

By installing these software packages, you will ensure that GitLab runs smoothly and efficiently on your Windows system.

Downloading GitLab Runner for Windows

Before setting up GitLab Runner on Windows, you need to download the GitLab Runner binary for Windows. The following steps outline how to download GitLab Runner for Windows:

  • Create a folder somewhere in your system, for instance, on the C drive. This can be created on any other drive, but for simplicity, we will use the C drive in this guide.
  • Go to the GitLab Runner download page and download the binary for 64-bit or 32-bit, depending on your system architecture. Save the binary to the folder you created in step 1.
  • Rename the binary to gitlab-runner.exe. This step is optional, but it is recommended for ease of use.

Once you have downloaded GitLab Runner for Windows, you are ready to install and register it. The next section will cover the installation process in detail.

Note that the GitLab Runner binary is a standalone executable that does not require installation. You can simply download the binary and run it from any folder on your system. However, it is recommended to keep the binary in a dedicated folder for ease of use and organization.

Installation and Configuration

Running the Installer

To install GitLab on Windows, the first step is to download the installer from the official GitLab website. Once the installer is downloaded, double-click on it to start the installation process.

During the installation, you will be prompted to choose the components you want to install. By default, all components are selected. However, if you do not need a particular component, you can deselect it to reduce the installation size.

After selecting the components, you will be asked to choose the installation directory. The default directory is usually fine, but you can change it if you want to.

Setting Up the GitLab Runner

Once the installation is complete, the next step is to set up the GitLab Runner. The GitLab Runner is a lightweight agent that runs jobs and sends the results back to GitLab. It can run on the same machine as GitLab or on a separate machine.

To set up the GitLab Runner, you need to first register it with GitLab. To do this, you will need to obtain a registration token from GitLab. You can find the registration token by going to the GitLab project’s Settings > CI/CD > Runner settings.

Once you have the registration token, open a command prompt and run the following command:

gitlab-runner register

This will start the registration process. During the registration process, you will be asked to provide the registration token, the GitLab URL, and the executor type. The executor type determines how the Runner will run the jobs. You can choose from several executor types, including Shell, Docker, and Kubernetes.

After providing the required information, the Runner will be registered with GitLab. You can now start using it to run jobs.

In summary, installing GitLab on Windows involves downloading the installer from the official website, running the installer, and setting up the GitLab Runner by registering it with GitLab. Once the Runner is set up, it can be used to run jobs and send the results back to GitLab.

Registering the Runner with GitLab

To register the Runner with GitLab, the user needs to obtain the registration token and run the runner registration command.

Obtaining Registration Token

Before registering the runner, the user needs to obtain the registration token from GitLab. To do this, the user should log in to their GitLab account and navigate to the project where the runner will be used. Then, the user should go to the project’s Settings > CI/CD > Runners page. On this page, the user can find the registration token that will be used to register the runner.

Runner Registration Command

Once the registration token has been obtained, the user can run the runner registration command in the command prompt. To do this, the user should open the command prompt and navigate to the folder where the GitLab runner was installed. Then, the user should run the following command:

gitlab-runner.exe register

This will initiate an interactive registration process, during which the user will be prompted to provide the URL of their GitLab server and the registration token obtained from the previous step.

The user will also be prompted to provide a description for the runner, which can be any string that describes the runner. This description will be used to identify the runner in GitLab.

After completing the registration process, the user can verify that the runner has been successfully registered by navigating to the project’s Settings > CI/CD > Runners page in GitLab. The runner should be listed on this page, along with its status and any associated tags.

In summary, registering the runner with GitLab requires obtaining the registration token and running the runner registration command in the command prompt. By following these steps, the user can set up the GitLab runner on their Windows machine and start using it for their CI/CD pipeline.

Verifying Runner Setup

After installing GitLab Runner on Windows, it is important to verify that it is correctly set up before using it to execute jobs. This section will guide you through the process of verifying the runner setup.

Checking Runner Status

To check the status of the runner, open a command prompt and navigate to the directory where GitLab Runner is installed. Then, run the following command:

gitlab-runner.exe status

This command will display the status of the runner, including whether it is running or not. If the runner is not running, you can start it by running the following command:

gitlab-runner.exe start

Registering the Runner

Before using the runner to execute jobs, it must be registered with GitLab. To register the runner, open a command prompt and navigate to the directory where GitLab Runner is installed. Then, run the following command:

gitlab-runner.exe register

This command will prompt you to enter the URL of your GitLab instance and the registration token. After providing this information, you will be prompted to configure the runner. Follow the prompts to configure the runner as needed.

Testing the Runner

After registering the runner, you can test it by creating a simple job in GitLab and executing it using the runner. To do this, create a new project in GitLab and add a .gitlab-ci.yml file to the root directory of the project. In this file, define a simple job that prints a message to the console.

For example:

stages:
- test
test:
stage: test
script:
- echo "Hello, world!"

Commit this file to the project and push it to GitLab. Then, navigate to the project in GitLab and click on the “CI/CD” tab. You should see the job you just created listed there. Click the “Run pipeline” button to execute the job using the runner.

If the job executes successfully, you have verified that the runner is correctly set up and ready to use.

Advanced Configuration

Using a Proxy Server

If you need to use a proxy server to access the internet, you can configure GitLab to use it as well. To do this, you need to modify the gitlab.rb configuration file.

  • Open the gitlab.rb file in a text editor.
  • Search for the http_proxy setting.
  • Uncomment the line by removing the # at the beginning of the line.
  • Set the http_proxy value to the URL of your proxy server, including the port number. For example: http://proxy.example.com:8080.
  • Save the file and reconfigure GitLab by running sudo gitlab-ctl reconfigure in the command prompt.

Configuring Concurrent Jobs

By default, GitLab is configured to run a maximum of 4 concurrent jobs for each runner. If you have a powerful machine, you can increase this value to speed up your CI/CD pipelines.

  • Open the config.toml file of your runner in a text editor.
  • Search for the concurrent setting.
  • Set the concurrent value to the number of concurrent jobs you want to run. For example: concurrent = 8.
  • Save the file and restart the runner service by running sudo gitlab-runner restart in the command prompt.

Note that increasing the number of concurrent jobs may put a strain on your machine’s resources, so make sure to monitor its performance and adjust the value accordingly.

Automating GitLab Runner as a Service

Automating GitLab Runner as a service is essential in ensuring that the runner is always available to execute pipelines. In this section, we will look at how to install GitLab Runner as a service on Windows and how to manage the service.

Installing as a Service

To install GitLab Runner as a service, follow these steps:

  • Open a Command Prompt window as an administrator.
  • Navigate to the GitLab Runner installation directory using the cd command. For example, if GitLab Runner is installed in C:\GitLab-Runner, run the following command:
  • cd C:\GitLab-Runner
  • Run the following command to install GitLab Runner as a service:
  • gitlab-runner install
  • This command installs GitLab Runner as a service and starts it automatically.
  • Set up the GitLab Runner configuration file by running the following command:
  • gitlab-runner register
  • This command prompts you to enter the GitLab URL and registration token, which you can find in the GitLab project’s CI/CD settings.

Service Management

Once GitLab Runner is installed as a service, you can manage it using the Windows Services console. To do this, follow these steps:

  • Open the Services console by pressing Win + R and typing services.msc.
  • Find the GitLab Runner service in the list of services and double-click on it.
  • In the GitLab Runner Properties window, you can start, stop, or restart the service. You can also change the startup type to Automatic, Manual, or Disabled.
  • Note: Changing the startup type to Disabled will prevent GitLab Runner from starting automatically when the computer starts.
  • Click on the Log On tab to change the user account that GitLab Runner uses to run. By default, GitLab Runner uses the Local System account, which has limited permissions. You can change this to a user account that has the necessary permissions to execute pipelines and access resources.
  • Note: Changing the user account requires that you enter the account’s password.

In conclusion, automating GitLab Runner as a service is a crucial step in ensuring that GitLab pipelines run smoothly on Windows. By installing GitLab Runner as a service and managing it through the Windows Services console, you can ensure that GitLab Runner is always available to execute pipelines.

Updating GitLab Runner

When using GitLab Runner on Windows, it is important to keep it up to date to ensure efficient CI/CD workflows, security, and access to new features. This section will provide a step-by-step guide to updating GitLab Runner on Windows.

Checking for Updates

To check for updates, the user should navigate to the GitLab Runner release page and download the latest version of the binary for 64-bit or 32-bit Windows systems. Once downloaded, the user should verify the SHA-256 checksum to ensure the file has not been tampered with.

Applying Updates

To apply updates to GitLab Runner, the user should follow these steps:

  • Stop the GitLab Runner service by running the following command in PowerShell as an administrator: Stop-Service gitlab-runner
  • Navigate to the folder where GitLab Runner is installed, typically C:\GitLab-Runner.
  • Rename the existing gitlab-runner.exe file to gitlab-runner-old.exe.
  • Copy the newly downloaded gitlab-runner.exe file to the same folder.
  • Start the GitLab Runner service by running the following command in PowerShell as an administrator: Start-Service gitlab-runner
  • Verify that the GitLab Runner service is running by running the following command in PowerShell as an administrator: Get-Service gitlab-runner
  • Verify that the GitLab Runner version has been updated by running the following command in PowerShell as an administrator: gitlab-runner --version

Following these steps will ensure that GitLab Runner is updated to the latest version and is ready to be used for CI/CD workflows.

--

--