5- What is Continuous Integration and Continuous Delivery? Why should it be used?
Tags: cicd, pipeline, sowtware, continousintegration
Published: 2022-03-07 13:40:57

> “In software, when something is painful, the way to reduce the pain is to do it more frequently, not less.”
> ― David Farley, Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation

I am here with another very important topic of the [Advanced Software Development](https://dev.to/hamitseyrek/0-advanced-software-development-23ak) article series. In this article, I will talk about **CI/CD**, which is an indispensable part of DevOps. If you've come this far by reading the series, it's fine. If you came directly to this article, I suggest you read the [0- Advanced Software Development](https://dev.to/hamitseyrek/0-advanced-software-development-23ak) article.

You are likely to have heard of the term CI/CD, both in the business world and in your own research. It is an integral part of DevOps, which was the subject of the previous article.

CI (Continous Integration) is a continuous control mechanism without integration after the code is developed. All developers send their changes periodically (usually daily) to the main server. It is very important that these changes do not affect each other or cause a new problem. Developers should review old commits before merging any changes they make. Although it does not pose a problem at first, it is both costly and difficult to manually check whether a change made in growing projects causes another problem in the system. Because there may be hundreds or even thousands of merges that have been made before. For this case, the term **[Integration Hell](http://wiki.c2.com/?IntegrationHell)** is used.

Automated tests are used to solve this problem. While running tests on a CI server requires passing tests to ensure integration, such servers also facilitate analysis, performance measurement, and QA of the source code.

Thanks to this continuous quality control (QA), both the software quality is improved and the job is delivered faster as no separate time is required for integration.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gzckt0dh9am2oc0q5z8n.png)

CD stands for continuous delivery and continuous deployment. Continuous integration starting with CI is continuously deployment on CD. The tests are run in the CI phase and the new version of the application is distributed in the CD phase.

The CI feedback loop provides automatic feedback to the developer by automatically performing tests for the entire given project in a short time.

You may have witnessed that the CI/CD pipeline  is viewed as unnecessary by some circles or is passed on as an overhead. But this is completely wrong. Because there are some steps that must be followed before a new version of a software product can be released.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6yz359tkzxmt6va3f7g7.png)
Performing the steps you see in the picture above manually without the CI/CD pipeline will take much more time, causing the team to work with lower performance. This naturally increases the cost of a software.
---
**A good Pipeline consists of these main parts:**

- Compiling and testing the code (Continuous Integration)
- Creating a ready-to-deploy build from code (Continuous Delivery)
- Automatically deploy the application to a server (Continuous Deployment)

The first step in a CI/CD pipeline for a good Pipeline is to have an automatic triggering system. The easiest way is to configure the CI/CD tool to check for changes in a Git repository. If you set up the pipeline bot to be run manually, this increases the cost and is sometimes forgettable. In an auto-triggered system, you have the peace of mind knowing that your code will be tested for every change.

CI tool **triggered** after auto-trigger checks the code in use Github, Bitbucket etc repository. The pipeline followed by compiling the code can do this very easily with Docker. Language-appropriate compilation is made in new environments to be created with container structures to be installed on Docker.

After the compilation phase, the **testing** phase is started. The CI/CD tool must be configured correctly for the tests to run correctly. It is also very important that being sustainable , as well as the tests are implemented and passed successfully . If you continue to develop the application and add new modules, but do not develop the tests in the same direction, this will endanger the sustainability of the application.

> The majority of your tests should be unit tests. Unit tests give you value for money. It is easy to write, inexpensive to run, and least costly to maintain. Martin Fowler

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ecytwllrrbfusbn8eobo.png)

After all tests are passed successfully, you can move on to **packaging** the code. How you package it depends on the programming language you use or your target environment. If you are using Docker, which is common use in DevOps, you can create a "Docker Image".

Now that we've done the packaging, we can start the **acceptance tests**. Acceptance testing is a way to make sure your software does what it's supposed to and meets the original requirements. For automatic acceptance tests, you can use the Selenium tool, which can simulate user behavior such as opening websites and clicking certain places.

Our software, which has successfully passed the acceptance tests, can now move on to "**Delivery and Distribution**" that is the final stage. You can now distribute your software, which has reached the Continous Delivery stage, thanks to a tool that enables distribution such as Kubernetes (Continous Deployment).

From now on, every code change you make in the software will start with the trigger phase and go through the same phases. For CI/CD Pipeline to be successful, great attention must be paid to testing, ease of use, and security.

Thus, **deployment** ceases to be big scary job done once after the whole project is finished, and becomes an easy process that is done regularly.

---

> The earlier you catch defects, the cheaper they are to fix. 
> ― David Farley, Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation

CI/CD is one of the most influential changes in the software development industry. Here are a few advantages of adopting CI/CD in your software development process:

- CI/CD has allowed companies to update and deliver their software faster.
- It made possible the possibility of controlled remote working.
- It provided more solid progress with the tests applied continuously.
- It saves time, as it provides instant feedback to the developers and solves the errors before they grow.
- It made the delivery step easier.

Most used CI/CD tools: **Jenkins, CircleCI, Bamboo, TeamCity, GitLab, Travis CI, Buddy …**

You can find more resources by researching the CI/CD actions of these tools. Regardless of the language you use, let me end this article by saying that you should definitely try to apply a few of the CI / CD tools :)

In the [Advanced Software Development](https://dev.to/hamitseyrek/0-advanced-software-development-23ak) series:

Previous article: "[4- What is DevOps? What are the benefits? What tools does it use?](https://dev.to/hamitseyrek/4-what-is-devops-what-are-the-benefits-what-tools-does-it-use-27fl)".

Next article: "[6- What is Agile Scrum methodology? What are the benefits to software development teams?](https://dev.to/hamitseyrek/6-what-is-agile-scrum-methodology-what-are-the-benefits-to-software-development-teams-cb2)".

Don't forget to like if you think it's useful :)

Always get better...