Day 8 : Jenkins: Automating Your Software Delivery Pipeline โจ๐ Part 1
Jenkins is a powerful open-source automation tool that enables Continuous Integration (CI) and Continuous Delivery (CD) of software projects. It streamlines the software development process by automating repetitive tasks and providing a framework for building, testing, and deploying code changes. Here's a step-by-step guide to setting up Jenkins for your project:
Installation and Setup ๐ ๏ธ๐ง
Update package list:
sudo apt update
Install OpenJDK 17 (Java Runtime Environment):
sudo apt install openjdk-17-jre
Check Java version:
java -version
Add Jenkins repository key and source to package manager:
curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.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
Install Jenkins:
sudo apt-get install jenkins
Check Jenkins status:
systemctl status jenkins
Retrieve the initial admin password:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Access Jenkins on your browser and follow the setup wizard.
Docker Integration ๐ณ
Install Docker:
sudo apt install docker.io
Add Jenkins to the Docker group:
sudo usermod -aG docker jenkins
Restart Jenkins:
sudo systemctl restart jenkins
Creating a Basic Pipeline ๐๐
Create a new pipeline job:
Name: YourJobName
Type: Pipeline
Configure the pipeline stages:
pipeline { agent any stages { stage("Code") { steps { echo "Code Cloned" } } stage("Build") { steps { echo "Code Built" } } stage("Test") { steps { echo "Code Tested" } } stage("Deploy") { steps { echo "Code Deployed" } } } }
Save and run the pipeline job.
Troubleshooting ๐ ๏ธ๐
Check ports in use:
sudo lsof -i:8001
Using Docker Compose:
docker-compose down docker-compose up -d
Benefits of Jenkins Pipelines ๐ก๐
Automation: Jenkins automates repetitive tasks, reducing manual errors.
Speed: Continuous Integration shortens feedback loops, accelerating development.
Reliability: Automated testing ensures code quality and stability.
Consistency: Pipelines enforce consistent processes across teams.
Traceability: Each pipeline run is recorded, aiding troubleshooting and audits.
Conclusion ๐๐
With Jenkins, you can build, test, and deploy software efficiently and reliably. By setting up pipelines, you establish a structured approach to software delivery, enhancing collaboration and quality. Embrace Jenkins to streamline your development lifecycle and deliver outstanding software with confidence! ๐๐