What is Jenkins?
→ Jenkins is an open-source tool used to automate tasks in software development, mainly focusing on Continuous Integration (CI) and Continuous Delivery (CD).
→ It also helps developers automatically build, test, and deploy their code changes whenever they make updates.
Features of Jenkins:
CI/CD INTEGRATIONS
PIPELINES
EASY INSTALLATION
EASY CONFIGURATION
DISTRIBUTED
EXTENSIBLE
OPEN-SOURCE
How to Set Up Jenkins in your Local Machine?
☆ There are many ways in which can set up you can choose which suits you the best
✦ You can set up in Windows also but I am going to teach you how we can setup Jenkins locally with Oracle VirtualBox VM.
✦ First create a VM (Virtual Machine) using a Virtual Box and install the Linux (Ubuntu/CentOS) as your wish
✦ Open Terminal in any one of the following Linux Distros it might be different for UBUNTU you can check Jenkins documentation for that I will guide you for CentOS.
sudo wget -O /etc/yum.repos.d/jenkins.repo \ https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
sudo yum upgrade
# Add required dependencies for the jenkins package
sudo yum install fontconfig java-17-openjdk
sudo yum install jenkins
sudo systemctl daemon-reload
✦ Start Jenkins by using systemctl
sudo systemctl enable jenkins
sudo systemctl start jenkins # to start jenkins
sudo systemctl status jenkins # to check the status if its running or not
✦ If everything went well, the beginning of the status output shows that the service is active and configured to start at boot(enabled)
✦ Now that Jenkins is up and running, let’s adjust our firewall rules so that we can reach it from a web browser to complete the initial setup.
IMPORTANT STEP :
✦ check if firewall is installed in the system
sudo yum install firewalld
sudo systemctl enable firewalld
sudo reboot
✦ Now everything is done now we can start using Jenkins
ifconfig
✦ By running this command we get the IP-Address of Linux system use this IP-Address to access the Jenkins dashboard in the web-browser by typing ipaddress:8080 and enter
✦ This will successfully Land you to this page:
✦ Use the terminal in your VM and run
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
✦ Copy the 32-character alphanumeric password from the terminal and paste it into the Administrator password field on the Jenkins page. Then, click Continue.
✦ Click on Install suggested plugins
✦ It will Install the required plugins
✦ Once all the plugins are installed then:
✦ Fill in the required fields and proceed
✦ URL will be provided i have removed for security purposes just click on save and finish
✦ Now you have successfully done the setup for Jenkins
✦ This is what the Jenkins Dashboard Looks like
Now this is for the Linux system it will only run in Linux environment if we want to access in our local machine (Windows) you need to follow certain steps:
In Linux environment run the following commands:
sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp
sudo firewall-cmd --reload
✦ Both the commands should give SUCCESS or else you have done something wrong
Setting Up Port Forwarding
Open VirtualBox VM settings.
Navigate to the NAT network adapter settings.
Click Advanced and then Port Forwarding.
Add a new rule named "Jenkins".
Set Protocol to TCP.
Enter Host IP as 127.0.0.1 and Host Port as 8080.
Guest Port should also be set to 8080.
Click OK to save the settings.
After this step→ Open your browser and go to 127.0.0.1:8080 to access Jenkins, you will land on the getting started Jenkins page:
✦ Enter the Username and Password which you created Before and there you go
✦ You have Successfully setup Jenkins in your Local Machine
How to create Jenkins first Job?
✦ Click on → Create a Job
✦ Then give a name for the job and select freestyle Project as we are just starting off.
✦ You will get a page something like this:
✦Choose the option what you like
✦We will choose Execute Shell and write the command that you want to execute and save
✦ Now just click on Build Now and that it you have successfully created your first job in Jenkins
✦ After the job is created click on the job and get to see the following:
✦ This was the output and we successfully created and saw the output of the command in Jenkins
✦ We can even see the number of jobs that we have created
Top comments (0)