Continuous Integration, Continuous Delivery, and Continuous Deployment Gitlab (CI/CD)

David Christianto
6 min readSep 20, 2023

--

Image source: https://medium.com/@ganiilhamirsyadi/deploying-and-maintaining-application-with-gitlab-ci-docker-and-elk-f23ed7a0b70c

Introduction

CI/CD is a process method in software development that automates every process performed to improve the efficiency, quality, and speed of software delivery. The goal of CI/CD is to ensure that the resulting website or application has reliable performance and minimal bugs.

CI/CD Pipeline:

Image source: https://www.clouddefense.ai/blog/how-to-implement-effective-ci-cd-pipeline

The continuous integration and delivery pipeline is appropriately referred to as an agile DevOps process since it not only helps teams stick to a frequent deployment schedule but also guarantees that builds respond to dependable product releases. This framework consists of up to

  • Continuous Integration
  • Continuous Delivery
  • Continuous Deployment

The following stages are carried out by a CI/CD pipeline:

  • Build: This is a step in continuous integration in which development teams build on top of source code and integrate new code.
  • Test: Software teams test using automated methods throughout both the continuous delivery and deployment stages.
  • Deliver: This is an automated stage in which the authorized code is forwarded to production. In continuous delivery, it is done with the developer’s consent, while in continuous deployment, it is done without human interaction.
  • Deploy: This is where the finished result is sent to production.

Continuous Integration (CI):

Image source: https://testrigor.com/blog/what-is-cicd/
  • Continuous Integration aims to make it easier for developers to integrate their work continuously. Especially in this day and age, many companies employ multiple developers at once for time efficiency.
  • Every time a code change is saved to the repository, the CI system automatically builds, tests, and checks the change to ensure that no errors occur or the change causes conflicts with existing code.
  • CI practices help identify problems early and allow teams to fix them immediately, which can reduce risks in software development.

Continuous Delivery (CD):

Image source: https://dzone.com/articles/what-is-continuous-delivery-the-benefits-and-best
  • Pushing applications to the delivery environment. An automated approach that pushes applications to the delivery environment. The development team supplies validated code changes (including updates, new feature additions, and bug fixes) made in continuous integration to the repository.
  • Serves as the link between Continuous Integration and Continuous Deployment, providing everything needed automatically.
  • The goal is to make the software delivery process more efficient and reliable. With CD, teams can ensure that software is ready to be released.

Continuous Deployment(CD):

Image source: https://www.atlassian.com/continuous-delivery/software-testing/continuous-deployment
  • The deployment stage completes the whole CI/CD process before the application is distributed to users.
  • It is dependent on well-designed test automation. Before production, no manual intervention takes place. If the code passes the automated tests, Continuous Deployment will transfer the changes made by the developer to the cloud application within minutes of scripting. Receiving and absorbing feedback becomes much easier this way.

What has been done for CI/CD section

In the previous pre-sprint section, I was assigned to create a product backlog based on user stories and features desired by users. In addition, I also took care of the group PRD file and worked on some parts of the SDS. However, through previous individual assignments, I learned how to construct a CI/CD where the deployment uses Vercel. And, from what I saw in the group repository that my groupmates had created, the gitlab-ci.yml file almost had the same content overall. So, I will explain the steps that I have taken to do a deployment using CI / CD

Step 1: create an online database using elephant.sql

This is because Vercel itself does not provide a database, so I have to create a separate database to do the deployment.

Step 2: Connecting the online database

I need to connect the online database to my code by putting the necessary credentials into my environment variable and setting it in settings.py.

Step 3: Create gitlab-ci.yml file

To build CI/CD, we need to run some automation commands to perform deployment by writing specific commands. The first is to enter the image, in this case, I use ubuntu:20.04. Next, specify the service used, namely postgres:11.5 and its cache paths, namely ~/.cache/pip/.

Before the whole script is run, define what commands must be run to prevent crashes or errors. This is defined by “before script:”

Then the next step is to enter the database credentials that were used and created earlier.

After that, determine through the script what stages will be automated by the CI / CD pipeline; in this case, I use 3 stages (build, test, and deploy). Then, define commands to perform migration automatically, including specifying stages and branches specifically. This is so that if changes occur in models.py, the system can immediately detect and update the changes that occur.

After that, write commands so that the system can test automatically as well as calculate code coverage.

The last step is to define commands to perform deployment automatically, which this block is marked with the “deploy_” keyword.

Step 4: Create a vercel token in the Vercel app

Go to the settings menu and select the token menu. Next, specify the token name, scope, and expiration date of the token to be created. This aims to integrate the Vercel app with GitLab as a repository.

Step 5: Inserting Vercel token into GitLab

Go to the settings menu and select CI/CD. Then insert the Vercel token that has been created to integrate Vercel and GitLab.

Step 6: The application is deployed

Reference source

--

--