Cloud Computing, DevOps

6 Mins Read

Overview of GitLab Runner and Guide to Perform CI/CD on GitLab

Voiced by Amazon Polly

Introduction to Git and GitLab

Git

  • Git is a version control system used to track changes in computer files. Git’s primary purpose is to manage any changes made in one or more projects over a given period.
  • It helps coordinate work among project team members and tracks progress over time. Git also assists both programmers and non-technical users by monitoring their project files.

GitLab

  • Gitlab is a service that provides remote access to Git repositories. In addition to hosting your code, the services provide additional features designed to help manage the software development lifecycle.
  • GitLab brings teams together to shorten cycle times, reduce costs, strengthen security, and increase developer productivity. These additional features include managing the sharing of code between different people, bug tracking, wiki space, and other tools for ‘social coding’.

What is CI/CD?

CI/CD is a subset of DevOps which combines the practices of continuous integration and continuous delivery. CI/CD automates much, if not all, of the manual human intervention required to get new code from commit to production, including build, test, and deploy, as well as infrastructure provisioning.

Continuous integration is the practice of early and regular integration of all your changes made into the main branch of a shared source code repository, automatically testing each change when you commit or merge it, and automatically starting a build.

Continuous delivery is a software development practice that, in conjunction with continuous integration, automates the provisioning of infrastructure and the release of applications.

Helping organizations transform their IT infrastructure with top-notch Cloud Computing services

  • Cloud Migration
  • Devops
  • AIML & IoT
Know More

What is GitLab CI/CD?

  • It is simple to learn, use, and scale.
  • It is a more efficient system for code deployment and development.
  • You can speed up the execution of the jobs by creating your runner (an application that processes the builds) with all pre-installed dependencies.
  • GitLab CI solutions are cost-effective and secure, with costs as flexible as the machine used to run them.
  • It enables project team members to integrate their work daily, allowing an automated build to easily identify integration errors.

What is GitLab runner?

  • GitLab Runner is a worker machine that executes your project’s GitLab CI jobs, through work stealing. Each Runner, as it becomes available, continually sends requests to the GitLab instance, asking to be assigned jobs.
  • Different Runners can have different capabilities (e.g. size, speed, or operating system), and they include these capabilities in their requests via tags that the GitLab Runner administrator includes in its configuration.

Steps to perform CI/CD on GitLab

Let us create a project file and commit it to the GitLab repo

Create a project file on your desktop and commit it to the GitLab repo

Step 1: Download git from https://git-scm.com/ and install git in your system.

Step1

Step1b

Step 2: To check if git is installed on your system enter the following command

Step2

Step 3: Run the following git commands. Enter GitLab username and email ID

Step3

Step 4: Create a demo project/folder & add it to git

Step4

Step4b

Step 5: Go to the command prompt and cd to the location of the folder and run the following commands.

Step5

Step5b

Step 6: Check the project (files) added on GitLab

Install GitLab runner on your PC. Go to the link given below:

https://docs.gitlab.com/runner/install/windows.html

– used in GitLab CI

– Open-source continuous integration service included with GitLab

– used to run jobs & send results back to GitLab

Step6

Step 7:

  1. Create a folder somewhere in your system, ex.: C:\GitLab-Runner.

Step7

  1. Download the GitLab Runner binary from the below link

https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-windows-amd64.exe

put it into the folder you created. The following assumes you have renamed the binary to gitlab-runner.exe

Step7b

  1. Run the command line with administrative rights

Step7c

Check the version of the GitLab-runner

Step7d

Step 8: Now we must register the GitLab-runner with the project associated with the GitLab

Enter the URL provided

gitlab-runner.exe register

It will prompt you to enter a registration code of the runner for your project to that create a project

Step8

Step 9: Create a project name my-first-project in your GitLab account

Step9

Step 10: Go to settings in your project under settings go to CI/CD Settings

Then go to runners expand the bar and go to the specific runner you will find the token available copy the token and paste it into the cmd

Step10

Give a name to your runner as my-runner1

Then enter the tags as ssh, ci and enter you would have successfully registered the runner

#ssh, ci

Step10b

You can go to the same path in the settings of your project to check for the specific runners registered

Step10c

Step 11: Add .gitlab-ci.yml in the root folder of your project

– GitLab CI/CD pipeline is configured using a YAML file called .gitlab-ci.yml in each project

– .gitlab-ci.yml file defines the structure and order of the pipeline & determines

Open a Notepad and paste the content given below

Step 12: Commit and push the file to the GitLab repo

Step12

Step 13: Make any change in the project -> commit -> push

Create a file named test2

Step13

Step 14: Give the following commands cmd

Step14

Step14b

Step 15: In your project go to CI/CD -> pipelines. You can see the pipelines passed

Step15

Note: If this error occurs in the pipeline stage

ERROR: Job failed (system failure): prepare environment: failed to start process: exec: “pwsh”: executable file not found in %PATH%. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information

Go to the installation directory of GitLab Runner e.g. C:\GitLab-Runner Here you will see config.toml file, open with notepad, and replace pwsh with powershell as below:

Step15b

Conclusion

Gitlab is a lifecycle tool that provides a vast repository of web-based DevOps. It provides issue tracking on CI/CD pipeline features by using an open-source license. The primary advantage of using GitLab is that it allows all team members to collaborate at all stages of the project. GitLab provides tracking from planning to creation to assist developers in automating the entire DevOps lifecycle and achieving the best results possible.

Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.

  • Cloud Training
  • Customized Training
  • Experiential Learning
Read More

About CloudThat

CloudThat is also the official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft gold partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.

Drop a query if you have any questions regarding GitLab and I will get back to you quickly.

To get started, go through our Consultancy page and Managed Services Package that is CloudThat’s offerings.

FAQs

1. What is Git?

ANS: – Git is a version control system that is used to keep track of changes to computer files. Git’s primary function is to manage changes made in one or more projects over a specified period.

2. What is Runner?

ANS: – GitLab Runner is a worker machine that executes your project’s GitLab CI jobs, through work stealing

3. What is CI/CD?

ANS: – CI/CD is a subset of DevOps (the integration of development and operations) that combines continuous integration and continuous delivery practices.

WRITTEN BY Swapnil Kumbar

Swapnil Kumbar is a Research Associate - DevOps. He knows various cloud platforms and has working experience on AWS, GCP, and azure. Enthusiast about leading technology in cloud and automation. He is also passionate about tailoring existing architecture.

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!

1