Jenkins Course - Day 1

Jenkins Course - Day 1

Jenkins Course - Day 1

Introduction to CI/CD Pipeline and Jenkins

What is a CI/CD Pipeline?

A CI/CD (Continuous Integration/Continuous Deployment) pipeline is a series of steps that must be performed in order to deliver a new version of software. It automates the integration of code changes from multiple contributors into a shared repository, and then automates the deployment of that code to production environments. Here are the key components:

  1. Continuous Integration (CI):

    • CI involves automatically building and testing code every time a developer commits changes to a version control repository like Git. This helps to quickly identify bugs and integration issues.

    • If any error occurs during CI, it sends a notification to the developer.

  2. Continuous Deployment (CD):

    • CD is the practice of deploying all code changes to a testing or production environment after the build stage. This ensures that the software is always in a deployable state.

What is Jenkins?

Jenkins is an open-source automation server that facilitates the CI/CD process. It helps in automating the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery.

Key Features of Jenkins:

  • It can run on any operating system.

  • Jenkins is written in Java, so Java is a prerequisite before installing Jenkins.

  • Jenkins was created in 2004 and has since become a widely used tool in the DevOps community.

  • It helps in quickly identifying bugs and errors in the CI process.

Jenkins Workflow

The typical workflow of Jenkins involves the following steps:

  1. Code Push: A developer pushes code to a version control system (like GitHub).

  2. Code Pull: Jenkins, through plugins, pulls the code from the version control system.

  3. Build: Jenkins builds the code using build tools like Maven.

  4. Testing: The built code is then tested.

  5. Deployment: After successful testing, the code is deployed to the production environment.

Each step in the process is facilitated through various plugins available in Jenkins.

Advantages of Jenkins

  • Extensive Plugin Ecosystem: Jenkins has a vast array of plugins available to integrate with various tools and technologies.

  • Framework, Not Just a Tool: Jenkins acts as a framework to create a CI/CD environment, rather than just a standalone tool.

  • Scalable Architecture: Jenkins follows a master-slave architecture to manage distributed builds and tasks efficiently.

Jenkins Architecture

  • Master: The Jenkins master is the central control unit of the Jenkins environment, responsible for managing:

    • Scheduling build jobs.

    • Dispatching builds to the slaves for the actual job execution.

    • Monitoring the slaves (possibly taking them online and offline as required).

    • Recording and presenting the build results.

    • Master also serves the Jenkins UI.

  • Slaves: Jenkins slaves are machines that are set up to build projects for the master. They run on a variety of operating systems and allow Jenkins to perform concurrent builds, making the overall CI/CD process faster and more efficient.

Steps to Install Jenkins

Before installing Jenkins, ensure the following prerequisites are installed:

  1. Git: For version control.

  2. Maven: For building Java applications.

  3. Java: Jenkins is a Java-based application, so having Java installed is essential.

Installation Steps:

  1. Install Java:

    • Download and install the latest version of Java from the official website.

    • Verify the installation by running java -version in the terminal.

  2. Install Git:

    • Download and install Git from the official website.

    • Verify the installation by running git --version in the terminal.

  3. Install Maven:

    • Download and install Maven from the official website.

    • Verify the installation by running mvn -version in the terminal.

  4. Install Jenkins:

    • Download the Jenkins .war file from the official Jenkins website.

    • Run the Jenkins .war file using the command: java -jar jenkins.war.

    • Access Jenkins by navigating to http://localhost:8080 in your web browser.

    • Follow the setup instructions provided by Jenkins to complete the installation.

Did you find this article valuable?

Support Aqib Hafeez(DevOps enthusiast) by becoming a sponsor. Any amount is appreciated!