Introduction To CI/CD

CI/CD stands for Continuous Integration & Continuous Delivery. Basically, the shipment of the software to predefined build, test, release, and deploy steps. This is the procedure for integrating the new code from development to production.

With a team that is moving with Agile, when you want to combine with DevOps culture, you need to automate these processes; therefore, the team can be more agile. CI/CD gains more importance after rising DevOps culture in teams.

Meantime, software development and delivery methodologies out-of-date, daily deployment cycle is growing. Before beginning to learn about CI/CD, you should at least have an idea about what DevOps is. You might need to update & upgrade these CI/CD pipelines quite often.

How does the CI/CD pipeline run?

Our deployment needs are getting more and more frequent in our applications. However, the security & code tests, the health checks, verifying and validating functionality, even load & stress tests for the new versions. In addition, these processes shouldn’t take to much time & while the deployment getting new versions in the production environment, end-users shouldn’t even realize that.

The Terminology

CI: Continuous integration concentrates on combining the software work products of specific developers collectively into a repository. The primary purpose is getting the detection of integration bugs with ease while allowing for more development collaboration.

CD: The aim of Continuous Delivery is to speed up between the key points that are inherent in the deployment or release processes. Typically, the team implements the involving automation for each step for build & release deployment safely.

Pipeline: To deploy apps, we need a set of actions that the dev team and ops team implement to build, test, and deploy apps. Each of these steps is part of a deployment pipeline. And the whole deployment process is carried out over this pipeline.

How to start writing a CI/CD Pipeline?

In this example, we will be using Jenkins as a CI/CD Tool. With his words: Jenkins is an open-source automation server which enables developers around the world to reliably build, test, and deploy their software.

Jenkins is typically run as a standalone application in its own process with the built-in Java servlet container/application server. For installing Jenkins: https://www.jenkins.io/doc/book/installing/

You can specify an agent for where the pipeline will be run. It can be a K8s pod, a Docker container, or just the server that Jenkins installed.
For more info: https://www.jenkins.io/doc/pipeline/tour/agents/

You can specify some directives that called options for pipeline specific configuration.
For more info: https://www.jenkins.io/doc/book/pipeline/syntax/#options

You can also specify post action to notifying a channel, trigger another job, or gather some files. And this post actions can be run regarding the pipeline’s status.
For more info: https://www.jenkins.io/doc/book/pipeline/syntax/#post

pipeline {
    agent {
        docker {
            image 'maven:3-alpine'
            args '-v /root/.m2:/root/.m2'
        }
    }
    options {
        skipStagesAfterUnstable()
    }
    stages {
        stage('Build') {
            steps {
                sh 'mvn -B -DskipTests clean package'
            }
        }
        stage('Test') {
            steps {
                sh 'mvn test'
            }
            post {
                always {
                    junit 'target/surefire-reports/*.xml'
                }
            }
        }
        stage('Deliver') {
            steps {
                sh './jenkins/scripts/deliver.sh'
            }
        }
    }
}

At the above pipeline, you can see the basic pipeline with creating a docker image of maven for the agent, build a packaging, testing and delivery stages. Also, you can add more additional steps as mentioned in previous titles.

Leave a Comment

Your email address will not be published. Required fields are marked *