In the ever-evolving landscape of software development, Continuous Integration and Continuous Deployment (CI/CD) have become indispensable practices. They ensure that development, testing, and deployment processes are seamless and error-free, leading to faster delivery and higher-quality software. One of the most popular tools used for CI/CD is Jenkins. In this blog post, we will explore the fundamentals of Jenkins and why it is a crucial component of the DevOps toolchain.
What is CI/CD?
CI/CD stands for Continuous Integration and Continuous Delivery/Deployment.
Continuous Integration (CI) is all about regularly combining code changes into a central repository. Each change is carefully checked using automated build and test tools, helping teams catch issues early on.
Continuous Delivery/Deployment (CD) goes a step beyond CI by automatically rolling out these code changes to real or test environments only when they pass the automated tests.
Continuous Deployment is an extension of Continuous Delivery where the deployment process is fully automated.
In the world of DevOps, CI/CD serves as a powerful collaboration tool. It brings developers and operations teams together, ensuring that the code is always ready to be deployed. This state of readiness enables organizations to swiftly respond to customer needs and market demands, ensuring that the software is always of top-notch quality.
Several well-known tools are available for creating CI/CD pipelines, including Jenkins, GitLab, CircleCI, Bamboo, Azure DevOps, and more.
What is Jenkins?
Jenkins is a DevOps tool written in Java, functioning as open-source software for continuous integration, continuous delivery, and deployment (CI/CD) automation. It is utilized to create workflows known as pipelines, enabling the implementation of seamless CI/CD processes.
Jenkins, an open-source automation server, plays a pivotal role in the CI/CD process. Jenkins is widely adopted because of factors like Extensive Plugin Support, Flexibility, Scalability, Community Support and Easy Integration.
Jenkins plugins facilitate the integration of diverse DevOps stages. To integrate a specific tool, you must install the corresponding plugins. For instance, tools like Git, Maven 2 project, Amazon EC2, and HTML publisher require their respective plugins for seamless integration.
Setting up Jenkins
Start an EC2 instance using Ubuntu as the base and establish a connection to it. I've adhered to the Jenkins official documentation for installing Jenkins on Linux.
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)
Jenkins requires Java 11 or 17 since Jenkins is 2.357 and LTS 2.361.1.
Step 1: Create an AWS EC2 instance and SSH into it.
Step 2: Install Jenkins on the EC2 instance.
Install Java
Update your system
sudo apt update
Install java
sudo apt install openjdk-11-jre
Validate Installation
java -version
It should look something like this
openjdk version "17.0.8.1" 2023-08-24 OpenJDK Runtime Environment (build 17.0.8.1+1-Ubuntu-0ubuntu122.04) OpenJDK 64-Bit Server VM (build 17.0.8.1+1-Ubuntu-0ubuntu122.04, mixed mode, sharing)
Install Jenkins
Just copy these commands and paste them onto your terminal.
curl -fsSL
https://pkg.jenkins.io/debian/jenkins.io.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
binary/ | sudo tee \ /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins
Start jenkins
sudo systemctl enable jenkins
sudo systemctl start jenkins
sudo systemctl status jenkins
On your AWS console, modify the security group for Inbound rules. Open port 8080 to your host from CustomTCP.
Verify Jenkins configuration by opening it in your browser.
Paste your hostIP:8080 in your browser. You should get the “Getting Started” page.
Since Jenkins is Apache tomcat based Web server (HTTP), the default is port 8080.
Retrieve the administrator password by utilizing the directory and your host through the given command.
You'll be directed to the "Customize Jenkins" page. Choose "Install recommended plugins."
After the installation is finished, the "Create First Admin User" page will show up. Enter the necessary information and proceed by clicking on Save and Continue.
Next, the "Jenkins is Ready!" page will be displayed. Click on "Begin using Jenkins" to proceed.
Well done! Jenkins has been installed on your host, and you've successfully connected to the Jenkins web server.
Step 3: Create a new item in Jenkins using freestyle project type.
Step 4: In the configuration section, navigate to the "Build" segment and include an "Execute shell" build step.
Step 5: Add the command to print “Hello World”.
Step 6: Click on "Save" to create the project.
Step 7: Now click on the “Build Now” to run the project.
Step 8: Check the console output for “Hello World” message.
Conclusion
In the fast-paced world of software development, adopting CI/CD practices is not just a choice but a necessity. Jenkins, with its versatility and powerful automation capabilities, simplifies the implementation of CI/CD pipelines. By automating repetitive tasks and ensuring the continuous integration and deployment of code changes, Jenkins empowers development teams to focus on innovation and delivering exceptional software products.
Embrace Jenkins and witness the transformation of your software development process. If you're not already using Jenkins, now is the time to explore its features and benefits. Your journey toward efficient, automated, and error-free software delivery begins here.
I hope you found this blog post helpful in understanding the significance of Jenkins in the world of CI/CD and DevOps. If you have any questions or want to connect and discuss more about Jenkins, CI/CD, or any other technology-related topic, please feel free to connect with me on LinkedIn. Let’s stay connected and continue our learning journey together!