Getting Started with Jenkins.

Getting Started with Jenkins.

What is Jenkins?

  • Jenkins is an open-source continuous integration-continuous delivery and deployment (CI/CD) automation software DevOps tool written in the Java programming language. It is used to implement CI/CD workflows, called pipelines.

  • Jenkins is a tool that is used for automation, and it is an open-source server that allows all the developers to build, test and deploy software. It works or runs on Java as it is written in Java. By using Jenkins we can make a continuous integration of projects(jobs) or end-to-endpoint automation.

  • Jenkins achieves Continuous Integration with the help of plugins. Plugins allow the integration of Various DevOps stages. If you want to integrate a particular tool, you need to install the plugins for that tool. For example Git, Maven 2 project, Amazon EC2, HTML publisher etc.

Jenkins installation.

  1. Create an EC2 instance for a remote Jenkins server. t2.micro

  1. Take ssh access and use the below commands to install Jenkins.

  • The important point is that when you want to install Jenkins, you first need to install Java sudo apt install openjdk-11-jre. Or openjdk-17-jre

  • Update the Debian apt repositories, install OpenJDK 17, and check the installation with the commands:

      sudo apt update
      sudo apt install fontconfig openjdk-17-jre
    
  • To check the Java version

        java -version
    
  • To install Jenkins

        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
    
        sudo apt-get update
        sudo apt-get install jenkins
    

  • To start Jenkins

      sudo systemctl status jenkins  
      sudo systemctl enable jenkins
      sudo systemctl start jenkins
      sudo systemctl status jenkins
    

Reference link for Jenkins installation on Ubuntu OS:- https://www.jenkins.io/doc/book/installing/linux/

What you understood in Jenkin, write a small article in your own words❓

Jenkins is a powerful open-source automation server that simplifies and streamlines various aspects of software development. It acts as a hub for automating tasks like building, testing, and deploying applications, and enhancing development workflows. With a user-friendly interface and an extensive collection of plugins, Jenkins enables teams to automate repetitive processes, integrate with version control systems, trigger builds on code changes, and ensure consistent software quality. This robust tool optimizes efficiency, minimizes manual errors, and accelerates the delivery of high-quality software, making it an essential asset for modern development pipelines.

What is Continuous Integration?

Continuous Integration is a software development method where team members integrate their work at least once a day. In this method, every integration is checked by an automated build to detect errors. This concept was first introduced over two decades ago to avoid "integration hell," which happens when integration is put off till the end of a project. In Continuous Integration after a code commit, the software is built and tested immediately. In a large project with many developers, commits are made many times during the day. With each commit, code is built and tested. If the test is passed, the build is tested for deployment. If the deployment is a success, the code is pushed to Production. This commit, build, test, and deploy is a continuous process, hence the name continuous integration/deployment.

Create a freestyle pipeline to print "Hello World!!"❓

Open the AWS console and in the security group open the ports.

Creating a simple freestyle pipeline in Jenkins involves creating a new Jenkins job and configuring it to execute a simple "Hello World!" print statement. Here's a step-by-step guide:

  1. Open your web browser and navigate to your Jenkins server's URL (e.g., ipv4:8080).

  1. Open server. Use command:
    sudo cat /var/lib/jenkins/secrets/initialAdminPassword

  2. Copy the output which is the password and use it for Jenkins Login.

  1. Click on Install suggested Plugins.

  1. Create the first admin User. Fill in the details, save and continue.

  1. Create a New Freestyle Job: Click on "New Item" on the Jenkins dashboard. Enter a name for your job (e.g. "Project django-todo-app-CI-CD-pipeline") and select "Freestyle project." Click "OK" to proceed.

  2. Configure the Job: You'll be taken to the job configuration page.

    a. General: You can provide a brief description of the job.

    b. Configure the Build Step:

    • In the job configuration page, scroll down to the "Build" section.

    • Click on the "Add build step" dropdown and select "Execute shell."

    • Click on "Add build step" and select "Execute shell" (for Linux/Unix) or "Execute Windows batch command" (for Windows).

c. Enter the Command
In the "Command" field, enter the command to print "Hello World!!".

        echo "Hello World!!"
  1. Save and Run:

    • Click "Save" to save the job configuration.

  • You'll be redirected to the job's main page. You can then manually trigger the job by clicking on the "Build Now" button.

  1. View Console Output: After the job has finished running, click on the build number under "Build History." This will take you to the build's page. Click on "Console Output" to see the printed "Hello World!" message.

Conclusion: Jenkins is a pivotal automation server driving efficient software development. Its CI/CD capabilities streamline processes, boost code quality, and foster collaboration. Customizable via plugins, Jenkins is a crucial tool for DevOps, enhancing automation and software delivery practices.

Stay in the loop with my latest insights and articles on cloud ☁️ and DevOps ♾️ by following me on LinkedIn https://www.linkedin.com/in/vinayak-salunkhe-devops-034a3a73/

I hope you enjoy the blog post!

If you find the blog helpful, please do like it and share it with your friends. If you have any doubts or questions related to the topics covered in the blog, feel free to ask them in the comments section. I’ll be more than happy to help!