✨🛠Getting Started with Jenkins[Step-By-Step Setup along with Free Style Project] ✨
🛠Before we jump to Jenkins, let's understand the situation before Jenkins(or before Continuous Integration).
🔔Manual Build Process
Developers have to wait until the complete software is developed for the test results.
If the test results show bugs then it was tough for developers to find those bugs because they have to check the entire source code of the application, which in turn slows the software delivery process.
The whole process was manual which increases the risk of frequent failure.
To overcome this manual build processing, Continuous Integration came into picture.
🔔Let's first understand how Continuous Integration is done ?
First you have to split the entire code into segments then you have to keep small segment of this manageable code after that make the required changes, then you have to integrate the segmented code like multiple times for days so that everyone has that code and they can coordinate with your team.
🔔What is Continuous Integration?
Continuous integration, often abbreviated as CI. It is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily. Each integration is verified by an automated build and tests to detect integration errors as quickly as possible. This approach reduced integration problems and allows a team to develop software more rapidly.
🛠Continuous Integration Workflow
🔔Benefits of Continuous integration
Immediate bug detection
Committing code frequently
Less context switching as developers are alerted as soon as they break the build
Spend less time debugging and more time adding features
Reduce integration problems allowing you to deliver software more rapidly
🔔Continuous Integration Tools
Some famous CI Tools are :
Jenkins
TeamCity
Bamboo
GitLab CI
🛠what is Jenkins 🚀
Jenkins is an automation tool written in Java with built-in plugins for continuous integration tasks. It is used to continuously build and test projects making it easier to integrate the changing codes to it.
It is a server-based system that runs in servlet containers such as Apache Tomcat. Jenkins is quite easy to configure, modify and extend. It deploys code instantly, generates test reports.
Jenkins is the most famous Continuous Integration tool, achieves Continuous Integration with the help of plugins. Plugins allow the integration of Various DevOps stages. If we want to integrate a particular tool, you need to install the plugins for that tool. For example Git, Amazon EC2, HTML publisher etc.
🔔Features of Jenkins 🤩
Easy Installation - Jenkins is a self contained java based program ready to run with packages for Windows, macOS and Linux operating systems.
Easy Configuration - Easy setup and configured via a web interface which includes error checks and built in help.
Plugins - Lots of plugins available in the Update Center and integrates with many tools.
Extensible - Jenkins can be extended by that plugin architecture which provides nearly infinite options for what it can be used for.
Distributed - Jenkins easily distributes work across multiple machines, helping to speed up builds, tests and deployments across multiple platforms.
Installing Jenkins 💥
Jenkins can be installed through native system packages, Docker, or even run standalone by any machine with a Java Runtime Environment (JRE) installed.
👉 Checkout this https://www.jenkins.io/doc/book/installing/ for Jenkins installation according to your requirements.
💥 In this blog, I will show step-by-step guide on how to install Jenkins on AWS EC2 instance.
✨Steps
Create a key pair using Amazon EC2.
Launch an Amazon EC2 instance
Install and configure Jenkins
✨Prerequisites
An AWS account, if you don’t have one, you can register https://aws.amazon.com/aispl/registration-confirmation/
Create a key pair: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-key-pairs.html#having-ec2-create-your-key-pair
🔔Task 1: Launch an Amazon EC2 instance
👉 Open the Amazon EC2 console by choosing EC2 under Compute.
👉 From the Amazon EC2 dashboard, choose Launch Instance.
👉 Then Choose an UBUNTU Server.
👉 Now, Choose an Instance Type , the t2.micro instance .
👉 In the Select an existing key pair or create a new key pair dialog box, select Choose an existing key pair, and then select the key pair you created or any existing key pair you intend to use.
👉click on Launch instances
⏩ In the left-hand navigation bar, choose Instances to see the status of your instance. Initially, the status of our instance is pending. After the status changes to running, instance is ready for use 🥳
👉Now open a terminal ,Follow the below steps
🔔Task 2: Create a freestyle pipeline to print "Hello World!!
Step 1: If you want to create on AWS Ubuntu you need to install Java.
Step 2: Copy this all commands & paste it on AWS terminal as it is.
sudo apt update #Update Package List
sudo apt install -y openjdk-11-jdk #Install Java 11
java --version #Check Java Install or not
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
sudo systemctl enable service
sudo systemctl start jenkins
sudo systemctl status jenkins
Step 3: Go to Security group, edit inbound rules add custom TCP
Select Port range 8080
& anywhere-IPv4
Save it.
Step 4: Access your Jenkins through your-public-IP: 8080
🔘 You'll get Jenkins dashboard, install necessary packages.
Configure Jenkins
Jenkins is now installed and running on your EC2 instance. To configure Jenkins:
📌 Connect to your_server_Public_IPv4_DNS:8080 from your favorite browser. You will be able to access Jenkins through its management interface:
📌 Use the following command for password:
cat /var/lib/jenkins/secrets/initialAdminPassword
📌 Now click on the Install suggested plugins. This will automatically install the important plugins..
📌 We can see below👇 that plugins start downloading…..
📌 Once the installation is complete, Create First Admin User, click Save and Continue.
So now , jenkins is ready to use 😀✌
📌 On the left-hand side, click Manage Jenkins, and then click Manage Plugins. Click on the Available tab, and then enter Amazon EC2 plugin at the top right. Select the checkbox next to Amazon EC2 plugin, and then click Install without restart.
Now , Let's run a simple job 🤩
👉 Click on New Item at the top left-hand side of your dashboard.
👉 Enter Item details
Enter the name of the item you want to create.
Select Freestyle project
Click Okay
👉 In Build Environment section, select Execute shell and write a simple command.
👉 Save the project
Click Apply
Save the project.
👉 Build Source code
Now, in the main screen, Click the Build Now button on the left-hand side to build the source code.
👉 See the console output
Click on the build number and then Click on console output to see the status of the build you run. It should show you a success message.
So , our job is successfully done 😀
I hope this blog will help you all in understanding Jenkins.
THANKS FOR READING !!
I think this blog will be quite valuable, offering unique viewpoints and introducing new and engaging ideas. 🙏
😊 Happy learning!