Introduction
Hey there, fellow DevOps enthusiasts and eager learners! Today, we're diving into the exciting world of continuous integration and continuous delivery (CI/CD), and we're kicking things off by shining a spotlight on one of the most pivotal tools in the game: Jenkins.
In this blog, we're going to break down Jenkins to its core, demystify the CI/CD workflow, and have an honest chat about the upsides and downsides of integrating a CI/CD tool into your development process. Plus, stick around till the end because we've got a hands-on task lined up for you to really put your newfound knowledge to the test.
So, grab a seat, buckle up, and let's embark on this journey together. Let's get started!
CI/CD
What is CI/CD?
CI/CD Continuous Integration and Continuous Deployment, is a process of automating an application deployment process that automatically deploys the application in real time, whenever there are changes made in the application.
This process reduces human intervention, which cuts down errors to bare minimum.
Continuous Integration (CI): This practice involves automatically integrating code changes from multiple developers into a shared repository frequently, typically several times a day. Each integration is verified by an automated build process (including tests) to detect integration errors as quickly as possible. CI aims to improve the quality of software, reduce integration issues, and provide rapid feedback to developers.
Continuous Deployment (CD): This extends CI by automatically deploying code changes to production environments after passing all tests. With CD, the entire process of deploying code, from integration to production, is automated. This automation reduces the risk of human error and accelerates the delivery of new features and updates to end-users.
Pros and Cons of CI/CD
Pros:
Faster Time to Market
Higher Quality Software
Increased Collaboration
Reduced Risk
Scalability
Cons:
Initial Setup Complexity
Resource Intensive
Overhead for Small Projects
Dependency on Automation
Security Concerns
Tools For CI/CD
The List of some of the widely used CI/CD tools are:
Jenkins
GitLab CI/CD
Azure DevOps
GitHub Actions
AWS CodePipeline
Jenkins
Jenkins is the powerhouse of continuous integration and continuous delivery/deployment (CI/CD) automation. Written in Java, this open-source DevOps tool serves as the backbone for implementing seamless CI/CD workflows, known as pipelines.
At its core, Jenkins is all about automation. It provides developers with a versatile platform to build, test, and deploy software efficiently. And because it's open-source, it's accessible to all, fostering collaboration and innovation within development teams.
Operating on Java, Jenkins ensures reliability and scalability in handling diverse automation tasks. Whether it's orchestrating CI processes or facilitating end-to-end automation, Jenkins has got you covered.
One of the key strengths of Jenkins lies in its extensibility through plugins. These plugins act as building blocks, enabling integration with various DevOps stages and tools. Need to integrate Git for version control? There's a plugin for that. How about Maven for project management? Yup, there's a plugin for that too.
Whether it's Amazon EC2, HTML publishing, or any other tool in your toolkit, Jenkins plugins pave the way for seamless integration and automation across your development pipeline.
How Does Jenkins Work
Here's a Step-by-Step procedure of how Jenkins work:
Setup: Jenkins is installed on a server and configured via a web interface.
Jobs: In Jenkins, tasks are automated through jobs. A job can represent a build process, a test suite, or any other automation task. Users can create new jobs via the Jenkins web interface or by defining job configurations in Jenkinsfiles (a Groovy-based DSL for defining Jenkins pipeline as code).
Triggers: Jobs are triggered manually or automatically based on events like code commits.
Execution: When a job is triggered, Jenkins allocates resources (like build agents) to run the job. These resources can be on the same server as Jenkins or distributed across multiple machines. Jenkins executes the steps defined in the job configuration, which could involve tasks such as compiling code, running tests, deploying applications, etc.
Feedback: Jenkins provides real-time feedback during job execution. Users monitor job progress, view logs, and receive status updates.
Integration: Jenkins integrates with version control systems and tools through plugins.
Extensibility: Jenkins has a rich ecosystem of plugins that extend its functionality. Users can install plugins to add support for additional version control systems, build tools, testing frameworks, cloud services, and more. Plugins allow Jenkins to be highly customizable and adaptable to different development environments and workflows.
Installation Guide
Software requirements:
- Java Should Be installed.
Installation of Java
Jenkins requires Java to run, yet not all Linux distributions include Java by default. Additionally, not all Java versions are compatible with Jenkins.
There are multiple Java implementations which you can use. OpenJDK is the most popular one at the moment, we will use it in this guide.
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
java -version
openjdk version "17.0.8" 2023-07-18
OpenJDK Runtime Environment (build 17.0.8+7-Debian-1deb12u1)
OpenJDK 64-Bit Server VM (build 17.0.8+7-Debian-1deb12u1, mixed mode, sharing)
For Linux:
On Debian and Debian-based distributions like Ubuntu you can install Jenkins through apt
.
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
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
Copy and Run the commands in the terminal to Install Jenkins.
For Other Operating system, visit Here.
Hands On Practice
Tasks:
1. What you understood in Jenkin, write a small article in your own words (Don't copy from Internet Directly)
2.Create a freestyle pipeline to print "Hello World!! Hint: Use link for Article
Don't forget to post your progress on Linkedin.
Conclusion
As we wrap up our discussion on Jenkins and CI/CD, it's clear that this tool is a game-changer in the world of software development. Jenkins doesn't just automate processes; it streamlines collaboration, enhances quality, and speeds up delivery. By breaking down complex setups and offering a plethora of plugins, Jenkins makes it easy for teams to adopt CI/CD practices.
As you embark on your Jenkins journey, remember to keep experimenting, learning, and sharing your experiences. After all, that's what the DevOps community is all about โ continuous improvement and collaboration.
Happy coding, and may your pipelines always run smoothly! I hope this blog added some value to your learning. Ending this with a quote
Everything you can imagine is real. - Pablo Picasso
Happy Learning