Mastering Continuous Integration and Continuous Deployment

Mastering Continuous Integration and Continuous Deployment

ยท

3 min read

Jenkins Jumpstart

  • Jenkins is an open-source project written in Java, that runs on Windows, macOS, and other Unix-like OS. It is a free community supported and might be your first choice tool for Cl (Continuous Integration).

  • Jenkins automates the entire software development life cycle.

  • Jenkins was originally developed by Sun Microsystem in 2004 under the name Hudson. The project was later named Jenkins when Oracle bought Microsystems.

  • It can run on any major platform without any compatibility issues.

  • Wherever developers write code, we integrate all that code and then build, test, and deliver/deploy to the client. This process is called CI/CD.

  • Because of Cl, bugs will be reported fast and get rectified fast. So the entire software development happens fast.

Workflow of Jenkins

  1. We can attach Git, Maven, Selenium, and Artifactory plugins to Jenkins.

  2. Once developers put code in GitHub, Jenkins pulls that code and sends it to Maven for Build or other build tools.

  3. Once the build is done, Jenkins pulls that code and sends it to Selenium for testing.

  4. Once testing is done, Jenkins will pull that code and send it to Artifactory as per requirement.

  5. We can also deploy with Jenkins.

Benifits of Jenkins

  1. It has a lot of plugins available.

  2. You can write your plugin.

  3. You can use community plugins.

  4. Jenkins is not just a tool. It is a framework, i.e. you can do whatever you want. All you need is just plugins.

  5. We can attach slaves (nodes) to Jenkins's master. It instructs others (slaves) to do Jobs. If slaves are not available, Jenkins itself does the Job.

  6. Jenkins also behaves as a Cron Server replacement, i.e. can do the scheduled task.

  7. It can create Labels.

What is a Node?

A machine that is part of the Jenkins environment and capable of executing Pipelines or jobs. Both the Controller and Agents are considered to be Nodes.

What is an Agent in Jenkins?

An agent is typically a machine, or container, which connects to a Jenkins controller and executes tasks when directed by the controller.

CI/CD Pipeline Overview

A CI/CD pipeline is a series of automated steps that code goes through from version control to production deployment. It consists of multiple stages, each representing a specific task or set of tasks. Common stages include code compilation, unit testing, code analysis, artifact creation, and deployment. Jenkins allows you to define and manage these stages, ensuring that the entire process is automated, consistent, and reproducible.

Installation of Jenkins on Linux

Jenkins installers are available for several Linux distributions.

  • Debian/Ubuntu.

  • Fedora.

  • Red Hat/Alma/Rocky

We'll be learning here about the installation on Debian/Ubuntu.

Prerequisites

Minimum hardware requirements:

  • 256 MB of RAM.

  • 1 GB of drive space (although 10 GB is a recommended minimum if running Jenkins as a Docker container).

  1. Update the system.

     sudo apt-get update
    
  2. Install Java.

     sudo apt install openjdk-17-jre
     java -version #Check version just to check if the installation is completed
     openjdk version "17.0.7" 2023-04-18
     OpenJDK Runtime Environment (build 17.0.7+7-Debian-1deb11u1)
     OpenJDK 64-Bit Server VM (build 17.0.7+7-Debian-1deb11u1, mixed mode, sharing)
    
  3. Add keys.

     curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
       /usr/share/keyrings/jenkins-keyring.asc > /dev/null
     echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
       https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
       /etc/apt/sources.list.d/jenkins.list > /dev/null
    
  4. Update packages again.

     sudo apt-get update
    
  5. Install Jenkins.

     sudo apt-get install jenkins
    
  6. Check Jenkins status.

     sudo systemctl status jenkins
    

Here are some Jenkins-specific questions related to Docker that one can use during a DevOps Engineer interview. These questions will help you in your next DevOps Interview. Click here.

ย