It doesn't matter what your role in the company is - a developer, business owner or CTO - the main goal is to deliver a qualitative product to the end audience and satisfy its needs.

Modern software development is navigating its way to agility and continuity. If you deliver products or features to your customer frequently - you fully control the situation, track the progress and reduce the risk of releasing a product of low quality.

In this article you'll learn about the benefits of continuous integration and delivery and most popular CI/CD tools.

What is continuous integration and why it is important

Continuous integration is a software development approach where each compiled code is verified by an automated tool before being merged. It allows to detect errors early in the development cycle.

Continuous integration is more than just a software development approach. It's a philosophy and mindset that drives developers to work as one team and always be on the same page.

Such practice prevents merge conflicts, bugs, and deviations in quality criteria and helps to build and release software as quickly as possible.

To better understand the concept of continuous delivery and integration, let’s see what development leaders think about it.

CI is a safety net that lets developers prevent many issues before they reach users. As a result, they ship code with more confidence, but not necessarily faster — the deployment process may still be

manual, long, and complicated.

Marko Anastasov - сofounder of SemaphoreCI.com

CI helps development teams avoid “integration hell” where the software works on individual developers’ machines, but it fails when all

developers combine (or “integrate”) their code.

Rod Cope - CTO at Rogue Wave Software

Continuous integration combines the integrate and test function, following the initial code/build process of agile development. It focuses on streamlining development, integrating code into shared repositories, and automating builds and tests to make it easier to

prevent and find problems more quickly.

Yaniv Yehuda - co-founder and CTO of DBmaestro

Source

Benefits of continuous integration

Benefits for business owners

CI/CD is not a domain of unicorn companies - each team from the startup to a large organization should practice this approach. Here are the main benefits it gives to businesses:

  • Accelerates time to market as your customers get upgrades faster

  • Reduces company’s expenses on manual labor

  • Increases productivity of your team by automating the tedious tasks

  • Helps to release a qualitative and error-free software

Benefits for developers

  • Faster debugging
  • Running the tests in the cloud
  • Frequent deployment
  • Running tests in a real-world stating environment
  • Visible progress of developers

I will dwell on 4 most available and budget options - Jenkins, TravisCI, GitLab and CircleCI and explain the benefits and drawbacks of each.

Jenkins

Jenkins

Jenkins is a leading open source automation server that can be used as a simple CI server or continuous delivery hub. Here are its main advantages:

  • Completely free

  • Hundreds of plugins

  • Jenkins is available for all platforms and different operating systems, whether OS X, Windows or Linux

  • Open-source and supported by a large community

In most cases, Kenkly is used for large projects. It provides a lot of plugins you need to install and customize as by default Jenkins has a limited number of features. So if you need to start quickly I don’t recommend using it.

TravisCI

Travis

Hosted continuous integration service used to build and test GitHub projects at no cost. For private projects, developers should buy an enterprise plan.

  • Makes it easy to test projects in any environment, device and operating system as it’s hosted on the cloud

  • Supports dozens of programming languages

  • Runs tests on Linux and Mac OS X simultaneously

Travis is recommended for open-source projects that need to be tested in different environments.

GitLab

GitLab

GitLab is the first single application for the entire DevOps lifecycle. GitLab CI/CD is a part of GitLab which provides a single workflow from planning to deployment.

  • Supports multiple platforms such as Unix, Windows, macOS, and any other platform that supports Go.

  • Parallel builds

  • Real-time logging

  • Local testing

  • Autoscaling

  • Docker support

  • Built-in container registry

CircleCI

cIRCLE-ci

Cloud based continuous integration and delivery platform for Linux, Mac OS and Android in the cloud or self-hosted. Circle CI is the best choice if you want to install and set up CI quickly.

  • Compatible with Python, Node.js, Ruby, Java, Go

  • Provides a free plan even for enterprise projects

  • No dedicated server required

  • Ability to install Circle CI on a private server

  • Automatic debugging feature

  • Runs in Docker containers, Linux VMs and macOS VMs

  • Connects with your toolchain like Github, Bitbucket, Fastlane, Azure, and Slack

How to set up continuous integration in CircleCI

Let's see how to set up CI on a ReactJS application with create-react-app script. Let's assume that we have already installed NodeJS on the local machine.

Ingredients:

To begin with, you need to install a new repository on GitHub

CI-1

Now you have to create new React application. Open the terminal and run the command create-react-app ci

After all the packages are installed, we can push our code on Github. To do this you have to open the repository directory and do the following:

git init git add . git commit -m “init” git remote add origin https://github.com/tarasromil/ci.git git push -u origin master

If you did everything right, your ReactJS app should be on GitHub.

Now you need to create Circle CI account. You can do this by signing in by your GitHub account.

Then choose the right Github organization on your dashboard

continious-integration-setup

You will see the list of all available repositories from your Github account. Choose recently created CI repository and click Set up project.

CI-repository

You can choose the operating system CI will work on.

Then choose a programming l-ge. In this case, it’s NodeJS.

Now let's see the example of your system configuration. First, you need to create a directory and file inside it by “.circleci/config.yml”

Below I will show the config that will make your system work. Insert it into “config.yml”, commit the changes and press Start build.

version: 2 # CircleCI API version
jobs: build: docker: # Specify the version you desire here. I'm using 9.11.1 - image: circleci/node:9.11.1 # Set a working directory working_directory: ~/ci # Describe the steps you will conduct steps: - checkout # Restore your cash - restore_cache: key: # Here you should indicate the unique key for your cache to increase the build performance # I use "package.json" and ".circleci/config.yml" - v1-dependencies-{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }} # Re-install node_modules for current version - run: yarn install # Now let’s save new cache - save_cache: paths: # We can indicate several directories or files for cashing - let’s make do with modules - node_modules # Indicate a new key for our cache key: v1-dependencies-{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }} # Run the tests - run: yarn test

You’ll see the list of your builds for a certain branch (in our case it’s master)and the details of each build - such as status, committer, execution time and even commit hash.

Now click on the last build. You will see the list that describes all the flow of build execution from installing the packages to running the tests.

In such a way we have quickly set our CI system.

What are the other possibilities?

Such systems allow not only to run integrational, E2E or other tests but also get the results of their completion (artifacts) - XML file or even screenshots. For this we have to create a directory and indicate the route to it.

run: name: Creating artifacts directory command: mkdir /tmp/artifacts
run: name: Creating test result directory command: mkdir -p /tmp/junit/mocha
run: name: Run tests command: yarn test
store_test_results: path: /tmp/junit
store_artifacts: path: /tmp/artifacts

Also there is an opportunity to set auto deployment of your program on hosting. Let’s add the command deploy into the section jobs and conduct it after tests have been run only on master branch. Here is the example of configuration:

version: 2
jobs: build: ... deploy: machine: enabled: true working_directory: ~/ci environment: HEROKU_APP: "ci-app" steps: - checkout - run: name: Deploy Master to Heroku command: | git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP.git master workflows: version: 2 build-and-deploy: jobs: - build - deploy: requires: - build filters: branches: only: master 

Conclusion

The biggest benefit you will get from continious integration and delivery is quality. The most importan tthing is to remember that CI/CD is not only about the right tools, it's about the right approach, rules, and mindset your company should adhere to. Have any questions on this topic? Leave a comment below and we will figure them out!