DevOps

Start DevOps with CircleCI – Stepwise Guide

CicleCI_main_image

Image Source:  https://circleci.com/

CircleCI is a CICD tool, that is, Continuous Integration – Continuous Deployment tool. It speeds up the deployment process by making it automated. One can execute complex workflows efficiently and quickly with sophisticated caching, Docker layer caching, resource classes for running on faster machines, and performance pricing.

What is CICD?

  1. Continuous Integration – Integrate all the features in your project to a single branch. Then use this branch for making builds, running tests, and checking test coverage and reports.
  2. Continuous Deployment – Once your code is ready, push the code to your main branch which is connected to a deployment tool like CircleCI. After that, the deployment process starts automatically and you do not need to do anything else.

So, this complete process makes the life of the developer a lot easier as compared to manual deployment. It saves time. Finally, it increases productivity. The risk of wrong code deployment can be avoided by adding the automated testing and unit testing scripts in the code itself.

CircleCI runs the builds created out of your code in clean containers or virtual machines and throws errors and stops the process of deployment in case of errors.

The developers get notified if tests fail/pass.

Stepwise Guide to Using CircleCI

  1. Create a repository in a VCS. You can use any VCS supported by CircleCI.
  2. Create branches as per your features.
  3. Write unit test cases as well as automated test cases, if needed, for the features.
  4. Create a single deployment branch.
  5. Add a yml file, that is a configuration file of CircleCI, to the deployment branch. Add all configurations in it. (We will cover configuration in another section.)
  6. Merge all features to the deployment branch. And push the commit.
  7. Once you push the commit the CircleCI pipeline starts automatically as per your configuration.
  8. The test cases will run and give you results. If they fail, the pipeline stops. If they pass the deployment process starts.
  9. After deployment is finished the automation script gets executed.
  10. Finally, code gets deployed successfully, and you will get an email notification of success or failure.

Advantages

So, in this complete process, the role of the developer is to code properly, do the correct configurations just once in the initial stage, and after that just push the code to the deployment branch, and wait for a notification from CircleCI. Isn’t that great for developers?

Also, in this complete automated process if you want a manual touch you can also configure things accordingly: like adding an approval or confirmation step before the actual deployment starts. This adds an extra layer of security during deployment.

A log of every deployment is maintained so you can trace which feature is pushed, and at what time.

In case you need to immediately revert to an older version of your code, you can just check the old deployment pipelines and restart that pipeline, and Voila! the old version is restored!

This process helps in saving time and prevents the terrible things that can happen if your team tries to change code in a hurry.

If you are using any other CICD tool you can easily migrate to CircleCI. The migration steps are given in their official documentation here:  https://circleci.com/docs/2.0/migration-intro/#section=getting-started

What is Supported

CircleCI supports deployment of almost all leading languages:

  • .NET
  • JAVA
  • JavaScript
  • React / React Native
  • C
  • Android

Configuration

  1. Create a directory called CircleCI in the root directory of your local GitHub or Bitbucket code repository.
  2. Create a yml file in that directory.

This file supports YAML, which is a human-friendly data serialization standard for all programming languages. It is a strict superset of JSON, another data serialization language. This means it can do everything JSON can… and more.

This is the only configuration file you will have in your project and usually, after all configurations are done, you will not need to update this file.

A sample config.yml looks like this:

configyml.png

  1. You need to modify the yml as per your need. Refer https://circleci.com/docs/2.0/configuration-reference/
  2. You also need to configure a few things on the CircleCI app.
  3. Log in or sign up using your GitHub account to CircleCI and add a new project there.
  4. Then set up your project repository there.
  5. Try by pushing a commit to your branch. If the CircleCI pipeline starts after pushing, you are done!

Start building with CircleCI today with their free plan: https://circleci.com/pricing/

For Additional Blogs –

DevOps & Automation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s