top of page

GitLab CI/CD for Beginners in 1 Hour [FREE Course]


GitLab CI/CD for Beginners in 1 Hour
GitLab CI/CD for Beginners in 1 Hour

In this GitLab Crash Course, I will teach you everything you need to know to get started with GitLab CI/CD in 1 hour 🚀 😊 This should give you a short overview and introduction.



Overview - What you’ll learn in 1 Hour

  • What is GitLab CI/CD

  • GitLab compared to other CI/CD platforms

  • Overview of GitLab Architecture

  • Build a full GitLab CI/CD pipeline for a Python demo app that

    • executes tests,

    • builds a Docker image,

    • pushes to a private Docker repository and

    • deploys the app to a remote server on DigitalOcean

The GitLab CI/CD pipeline we will build
The GitLab CI/CD pipeline we will build

Learn GitLab Basic Concepts on the way:

GitLab CI/CD what you learn
  • Pipeline, Jobs,

  • Stages

  • GitLab Runners and Executors

  • Variables (Variable and File Type)

  • Docker in Docker





What is GitLab CI/CD?


First of all, what is Gitlab CI/CD, and why should you even care?


GitLab platform generally is striving to become THE DevOps platform or a one-stop shop for building DevOps processes for your applications. 🚀


GitLab platform covers many steps of the DevOps process
GitLab platform covers many steps of the DevOps process

So they have exactly this roadmap, and they're working towards that, which means they're actually integrating and creating new features to basically give you everything in one platform to build complete DevOps processes, and a big part of those processes is a CI/CD pipeline.



What is CI/CD in simple words


So, first of all, what is CI/CD in simple words?


CI/CD stands for Continuous Integration and Continuous Deployment or Continuous Delivery, and what it basically means is automatically and continuously testing, building, and releasing code changes to the deployment environment.


So that means when a developer commits a new code into the Gitlab repository, Gitlab will automatically execute a CI/CD pipeline that you have configured for your project to release those code changes to the end environment, where the end users can access them:


What is CI/CD?
What is CI/CD?

But this CI/CD concept is a topic of its own. If you want to understand it on a deeper level, then you can check out my video about DevOps and CI/CD pipeline, where I explain this in more detail here: What is DevOps?


But as I said, in simple terms, CI/CD is to continuously release your code changes to the end environment, and in this crash course, we will be building a simplified version of a CI/CD pipeline using Gitlab CI/CD.


Many CI/CD platforms

Of course, there are many CI/CD tools, one of the most used ones in the industry still being Jenkins. And Gitlab CI/CD is just one of those other CI/CD platforms:


There are many CI/CD platforms available
There are many CI/CD platforms available

Source Code & CI/CD on the Same Platform


All of them have their advantages and disadvantages. Still, a big advantage of using Gitlab to build CI/CD pipelines for your applications is that you already have your code on Gitlab, so this is an extension of your software development processes in your team, where you can also build CI/CD pipelines on the same platform:

Source Code Management on GitLab
Source Code Management on GitLab

So your team already works with Gitlab, and you have your code there, so this is basically an additional feature that you can extend your workflows on Gitlab with, and you don't need a separate tool for that. 👍


Apart from that, Gitlab makes that extension very seamless by allowing you to get started without any setup effort and also having your pipeline as part of your application code compared to Jenkins, for example, where you have to set up and configure the Jenkins server, create a pipeline and then connect it to the Git project:

GitLab vs Jenkins
GitLab vs Jenkins

With Gitlab, you can start without any of this configuration effort, and we will see that in the demo part. ✅



GitLab Architecture


Now if you don't have to set up anything and configure any servers to run the pipelines, how does it actually work? And this leads us to the topic of Gitlab architecture and how it works.


GitLab Instance

You have a Gitlab instance or also called Gitlab server, that hosts your application code and your pipelines and basically the whole configuration. So it knows what needs to be done.


GitLab Runners

And connected to that Gitlab instance, you have multiple GitLab runners, which are separate machines connected to the Gitlab server machine, which are actually the ones executing the pipelines.


So the Gitlab server knows what needs to be done, and the GitLab runner actually does that:

GitLab Architecture
GitLab Architecture

Managed or SaaS

And www.gitlab.com is actually a managed Gitlab instance that offers multiple managed runners already out of the box.

So these are all maintained by Gitlab, and that's why you can start running your pipelines without any setup and configuration effort using this managed setup.


Self-Managed

And this is already enough for starting out, but of course, for your own organization, you may want to manage the runners or the whole setup yourself.


So you can create partially or completely self-managed GitLab setup as well:

GitLab SaaS vs Self-Managed
GitLab SaaS vs Self-Managed

In this crash course, we will use Gitlab's managed infrastructure and free features to build our release pipeline. So we will not need to configure anything ourselves. 👍



Pipeline Configuration - .gitlab-ci.yml


Now the question is, how do we create a Gitlab CI/CD pipeline? 🤔


Well, following the concept of Configuration as Code or Pipeline as Code, the whole pipeline will be written in code and hosted in the applications git repository itself in a simple YAML file.


And the file has to be called .gitlab-ci.yml, so that Gitlab can automatically detect that pipeline code and execute it without any extra configuration effort from our site:

Configuration of the pipeline as code
Configuration of the pipeline as code

So in the root of the project's repository, we're going to create this YAML file, and we're going to write all the pipeline configurations inside. We can actually do that directly in the GitLab UI as well, so we don't have to switch back and forth from the editor to Gitlab:

Using GitLab UI
Using GitLab UI

Jobs

The tasks in the CI/CD pipeline, such as running tests, building an image, deploying to a server, etc., are configured as what's called 'jobs':


What are the tasks in the CI/CD pipeline?
What are the tasks in the CI/CD pipeline?

GitLab jobs
GitLab jobs

So jobs are the most fundamental building block of a .gitlab-ci.yml file. They define what to do.


Each job has a name, and inside the job, we have a couple of parameters or a couple of attributes or things that we want to configure for the job.


The first attribute and the only required attribute of a job is what's called a script. And the script is basically where we list any commands that should be executed for that job:

Example configuration for GitLab jobs
Example configuration for GitLab jobs

So, for example, for 'run tests', we need to execute make test for our python demo application. This is the command that needs to be executed in order to run the test, so we're going to write that command:

Example GitLab configuration for running tests and building Docker image
Example GitLab configuration for running tests and building Docker image

However, in order for this to run successfully, we need to do a couple of things.


But for the actual demo part, let's continue with the video, so you can follow along more easily: 🤓



▬▬▬▬▬▬ R E F E R E N C E S 🔗▬▬▬▬▬▬ ► Git repo we build the CI/CD pipeline for: https://gitlab.com/nanuchi/gitlab-cicd-crash-course


▬▬▬▬▬▬ Course Pre-Requisites ▬▬▬▬▬▬

💡 Docker - learn here: ► https://youtu.be/3c-iBn73dDE 💡 YAML - learn here: ► https://youtu.be/1uFVr15xDGg


Hope you will learn a lot in this beginner tutorial!


 

Complete GitLab CI/CD course with Docker, Kubernetes and Microservices 🚀


Also if you are serious of learning GitLab CI/CD, be sure to check out our complete GitLab CI/CD course. You will learn how to build production-ready CI/CD pipelines in one comprehensive and practical course!

4 Comments


Joann Miller
Joann Miller
6 days ago

Thank you for the clear introduction. I learned a lot!

drift hunters

Like

bringing their own unique style and flair. One character whose fashion stands out is Evie, the daughter of the Evil Queen. Known for her impeccable style and enchanting wardrobe, Evie’s jacket has become a beloved fashion piece among fans. Let's evie's jacket from descendants into what makes Evie’s jacket from "Descendants" so iconic and how you can incorporate it into your wardrobe.

Like

This free and accelerated course on GitLab CI/CD helps Beginners like geometry dash online not waste time. Thanks.

Like

Laslo Keller
Laslo Keller
Oct 11, 2023

Thank you for the simple and clear explanation of this ci/cd technology. I met this technology for the first time when I was working on the website of the https://gainswave.com/ clinic. I use this tool quite often now, but not all the time. Sometimes I use github.

Like
bottom of page