Setting Up Jenkins & Creating Your First Pipeline😃
Today, we’ll be focusing on installing and configuring Jenkins on our systems. Additionally, we’ll take on an exciting challenge—creating a freestyle pipeline to apply what we've learned. Ready to enhance your automation skills? Let’s get started! 💻🔧
Setting Up Jenkins
Prerequisites:
Minimum hardware requirements:
256 MB of RAM
1 GB of drive space (10 GB recommended if running Jenkins as a Docker container)
Java 11 or 17 is required.
Installing Jenkins:
Update the Packages:
sudo apt-get update
Install Java:
sudo apt install openjdk-11-jre
Check Java Installation successful or not:
java --version
Add Jenkins Repository Key:
curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
Add Jenkins Repository:
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
Update Package Lists and Install Jenkins:
sudo apt-get update sudo apt-get install jenkins
Start Jenkins:
sudo systemctl start jenkins
Check Jenkins Status:
systemctl status jenkins
Open Port 8080 on your EC2 Instance: Since Jenkins by default runs on port 8080 thus we are allowing this port the permission.
Access Jenkins Web Interface: Open a web browser and enter the public IP address of your EC2 instance followed by
:8080
(e.g.,http://<your_public_ip>:8080
).To retrieve the Jenkins initial admin password, enter the following commands in your Linux terminal:
💡/var/lib/jenkins/secrets/initialAdminPasswordThen, run:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
This will generate the admin password required for your first login.
Find Admin Password: Go to the specified Path on your EC2 instance as mentioned above to get Administrator Password.
Customize Jenkins:
Congratulations, your setup is ready and we are ready to use it.
Task: Create a Freestyle Pipeline to Print "Hello World"
Go to New Item on Dashboard on top left.
Enter Item name and select on Freestyle Project and click ok.
Give a description about what your project is about for others to understand easily.
Select "Execute Shell" in Build Steps.
Give the required steps to execute. Since here we only want to print Hello World thus we have only 1 command which is echo command.
Click on Build Now on left to start.
The green tick shows that the project ran successfully.
Console output shows what was the output and thus verifies the success. We finally see the output "Hello World" which we wanted.
Conclusion
In conclusion, Jenkins stands as a cornerstone of modern DevOps practices, providing a robust platform to automate the entire software delivery process. With its powerful pipeline features and extensive plugin ecosystem, Jenkins significantly improves the efficiency and reliability of CI/CD workflows. As emphasized by Deepesh Gupta, embracing Jenkins can elevate your automation skills to new heights! 🚀
Subscribe to my newsletter
Read articles from Deepesh Gupta directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Deepesh Gupta
Deepesh Gupta
DevOps & Cloud Enthusiast | Open Source Contributor | Driving Technological Excellence in DevOps and Cloud Solutions