What is CICD and why is it so Popular?

What is CI/CD?

CI/CD is a set of practices that automate the building, testing, and deployment stages of software development. Automation reduces delivery timelines and increases reliability across the development life cycle.

Most modern applications require developing code using a variety of platforms and tools, so teams need a consistent mechanism to integrate and validate changes. Continuous integration establishes an automated way to build, package, and test their applications. Having a consistent integration process encourages developers to commit code changes more frequently, focus on meeting business requirements, code quality, and security, which leads to better collaboration and code quality.

Continuous integration and continuous delivery are two distinct processes in CI/CD and have different purposes:

  • CI runs automated build-and-test steps to ensure that code changes reliably merge into the central repository.
  • CD provides a quick and seamless method of delivering the code to end-users.

So the main goal of CI/CD is to help developers ship software with speed and efficiency. The team continuously delivers code into production, running an ongoing flow of new features and bug fixes.

The most popular CI/CD tools

A CI/CD tool helps DevOps teams create a pipeline and automate integration, deployment, and testing stages. Some tools specifically handle the integration (CI) side, some manage development and deployment (CD), while others specialize in continuous testing or related functions.

Here is a list of the most popular CI/CD tools you can choose from:

  • Jenkins: An automation server that can handle anything from simple CI to a complex CI/CD pipeline.
  • TeamCity: A CI server that helps build and deploy projects with reusable settings and configurations.
  • Spinnaker: An open-source CD platform ideal for multi-cloud environments.
  • GoCD: A CI/CD server that emphasizes modeling and visualization.
  • CircleCI: A flexible, cloud-based CI/CD tool perfect for smaller projects.
  • Travis CI: A Ruby-based tool with a robust build matrix.
  • Bamboo: A CI server with support for several top stacks (Docker, AWS, Amazon S3, Git, CodeDeploy, Mercurial) and up to a hundred remote build agents.

CI/CD enables more frequent code deployment.

So, let’s sum up

CI packages, tests builds, and notifies developers if something goes wrong. The CD automatically deploys applications and performs additional tests.

CI/CD pipelines are designed for organizations that need to make frequent changes to applications with a reliable delivery process. In addition to build standardization, test development, and deployment automation, we get a holistic production process for deploying code changes. The introduction of CI/CD allows developers to focus on improving applications and not spend effort on deploying it.

CI/CD is one of the DevOps practices, as it aims to combat the tension between developers who want to make frequent changes and operations that require stability. With automation, developers can make changes more frequently, and operations teams, in turn, gain greater stability because environment configuration is standardized and continuous testing is carried out during delivery. Also, the setting of environment variables is separated from the application and there are automated rollback procedures.

However, CI/CD is just one of the processes that can contribute to improvements. There are other conditions for increasing the frequency of delivery.

To get started with CI/CD, the development and operations teams need to decide on technologies, practices, and priorities. Teams need to build consensus on the right approaches for their business and technology so that once CI/CD is implemented, the team consistently adheres to the chosen practices.

Deploy Using Git Pull

Automatically pull files from bitbucket git repo upon commit/merge to master.

Whenever there’s a need to deploy by means of an automated git pull, without the whole container,  docker registry, aws overhead, the code below works best.

exec(“git pull https://username:password@bitbucket.org/company/repo.git master”);

Here are the step-by step instructions

  1. Create a user on bitbucket with access to the desired repository.
  2. SSH to your remote server, where the code should be pulled to.
  3. Clone the repository into the desired directory:  git clone https://username:password@bitbucket.org/company/repo.git
  4. Create a script (python, php or shell) – doesn’t matter. The “exec” command above is for php.  Script should be accessible from the web.
  5. Add a webhook to the repository on bitbucket, where the triggered url is the url to the php script.

All done! Now every time there’s a change to master, the code will be pulled by the remote server.

Why use username and password and not SSH keys?

SSH keys won’t work for a number of reasons, but anyone is free to give it a shot and let us know how it went. Note, the script is executed by the webserver, which runs under it’s own user that naturally has no access to the private key. Trying to make the keys available for that user is  not worth the headache.

Bitbucket’s own documentation has an FTP example, why not use that?

The whole FTP business is not secure and not that widely used. If one can avoid spinning up an FTP server, one probably should.

Below are a few search queries suggested by google, left here to help those seeking the solution to their problem 🙂

How to sync with git repository

Bitbucket pull via ftp sftp

Deploy using ftp sftp

Automate git pull

Simplest continuous integration

Отладка. Будет убрана потом