You are on page 1of 15

Basics of GITLAB CI/CD

Deepak Bansal & Mohak Gupta


T-tool team,
Techno Foundation, SBS India.
What is GITLAB ?

GitLab is a Git-based repository manager and a powerful complete


application for software development. With an "user-and-newbie-friendly"
interface, GitLab allows you to work effectively, both from the command line
and from the UI itself.

• Mattermost
• Issue tracker
• Issue Board
• GitLab CI

GitLab is a complete DevOps platform


What is CI ?

Consider an application that has its code stored in a Git repository in


GitLab. Developers push code changes every day, multiple times a day. For
every push to the repository, you can create a set of scripts to build and test
your application automatically, decreasing the chance of introducing errors
to your app.

This practice is known as Continuous Integration; for every change


submitted to an application - even to development branches - it’s built and
tested automatically and continuously, ensuring the introduced changes
pass all tests, guidelines, and code compliance standards you established
for your app.
What is CD ?

Continuous Delivery is a step beyond Continuous Integration. Your


application is not only built and tested at every code change pushed to the
codebase, but, as an additional step, it’s also deployed continuously, though
the deployments are triggered manually.
This method ensures the code is checked automatically but requires human
intervention to manually and strategically trigger the deployment of the
changes.

Continuous Deployment is also a further step beyond Continuous


Integration, similar to Continuous Delivery. The difference is that instead of
deploying your application manually, you set it to be deployed automatically.
It does not require human intervention at all to have your application
deployed.
What is Gitlab CI/CD ?

GitLab CI/CD is a powerful tool built into GitLab that allows you to apply all
the continuous methods (Continuous Integration, Delivery, and Deployment)
to your software with no third-party application or integration needed.
What is CI/CD pipeline
Gitlab CI/CD Architecture
Why Gitlab CI/CD

https://about.gitlab.com/blog/2016/10/17/gitlab-ci-oohlala/
https://about.gitlab.com/blog/2019/04/25/5-teams-that-
made-the-switch-to-gitlab-ci-cd/
What are the advantages of GitLab CI/CD?

•Integrated: GitLab CI/CD is part of GitLab, enabling a single conversation from


planning to deployment (and beyond)

•Open source: CI/CD is a part of both the open source GitLab Community Edition and
the proprietary GitLab Enterprise Edition

•Easy to learn

•Seamless: Part of the single GitLab application, with a single great user experience

•Scalable: Tests run distributed on separate machines of which you can add as many
as you want

•Faster results: Each build can be split in multiple jobs that run in parallel on multiple
machines

•Optimized for delivery: multiple stages, manual deploy


gates, environments, and variables.
How many of you uses Jenkins? ? ?

JENKINS PROS JENKINS CONS

selfhosted –> full control over workspaces overhead for small projects as you have to setup by
yourself
easier debugging of runners hence full workspace complicated plugin integration
control
very good management of credentials. new pipeline for every environment (e.g.
Production/Testing)
big plugin library

GITLAB PROS GITLAB CONS

very good Docker integration artifacts have to be defined and


uploaded/downloaded for every job
parallel job execution within stages testing the merged state of a branch is not possible
before actual merge is done
easy to add jobs stages within stages are not yet supported

merge request integration

extremely scalable due to concurrent runners


Let’s try our hands on it..

Gitlab Project.
Runner for this Gitlab project.
Let’s go …
Gitlab YML file.

Starting….

Lets create a blank project on Git.


Start developing the CI without code only. We can just try CI/CD by running
Some plain commands only.

And add a plain file .gitlab-ci.yml to it.


What is .gitlab-ci.yml file?

In this file, you can define the scripts you want to run, define include and
cache dependencies, choose commands you want to run in sequence and
those you want to run in parallel, define where you want to deploy your app,
and specify whether you will want to run the scripts automatically or trigger
any of them manually. Once you’re familiar with GitLab CI/CD you can add
more advanced steps into the configuration file.

To add scripts to that file, you’ll need to organize them in a sequence that suits
your application and are in accordance with the tests you wish to perform. To
visualize the process, imagine that all the scripts you add to the configuration
file are the same as the commands you run on a terminal on your computer.
Once you’ve added your .gitlab-ci.yml configuration file to your repository,
GitLab will detect it and run your scripts with the tool called GitLab Runner,
which works similarly to your terminal.

The scripts are grouped into jobs, and together they compose a pipeline.
What is Gitlab Runner ?

GitLab Runner is the open source project that is used to run your jobs
and send the results back to GitLab. It is used in conjunction
with GitLab CI, the open-source continuous integration service
included with GitLab that coordinates the jobs.

You might also like