Day 25 Task: 🚀Complete Jenkins CI/CD Project - Continued with Documentation 📄

"I'm a 3rd-year Computer Engineering student at Marwadi University with skills in C++, web development (MERN stack), and DevOps tools like Kubernetes. I contribute to open-source projects and share tech knowledge on GitHub and LinkedIn. I'm learning cloud technologies and app deployment. As an Internshala Student Partner, I help others find jobs and courses." now currently focusing on #90DaysOfDevops
Introduction
We completed till day 24 , we deployed project through cicd pipeline and learn aboout github hooks and many things so in this blog i made documentation about what we learned in jenkins
Steps for Jenkins CI/CD Project
Let's dive into the detailed documentation.
GitHub Setup
Create a GitHub Account: If you don't already have a GitHub account, you can create one by following the steps in Creating an account on GitHub.
Create a GitHub Repository: Once your account is set up, create a new repository by following the instructions in Create a GitHub Repository.
Set Up Git Configuration:
Open your terminal or command prompt.
Configure your Git username and email:
git config --global user.name "Your Name" git config --global user.email "your-email@example.com"
Clone the Repository:
Copy the repository URL from GitHub.
Clone the repository to your local machine:
git clone https://github.com/your-username/your-repository.git
Initialize Git Repository:
Navigate to your project directory:
cd your-repositoryInitialize the Git repository:
git init
Add Files:
Add your project files to the repository:
git add .
Commit Changes:
Commit your changes with a message:
git commit -m "Initial commit"
Push Changes:
Push your changes to the remote repository:
git push origin main
Docker and jenkins installation in ubuntu
Install Docker:
Update your package list:
sudo apt-get updateInstall Docker:
sudo apt-get install -y docker.io
Install Docker Compose:
Download the Docker Compose binary:
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-composeApply executable permissions:
sudo chmod +x /usr/local/bin/docker-compose
Install Java:
Install Java Development Kit (JDK):
sudo apt-get install -y openjdk-11-jdk
Add Jenkins Repository Key:
Add the Jenkins repository key:
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
Add Jenkins Repository:
Add the Jenkins repository to your sources list:
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
Install Jenkins:
Update your package list and install Jenkins:
sudo apt-get update sudo apt-get install -y jenkins
If you phase any problem then follow this link jenkins installation
Jenkins Service:
Start the Jenkins service:
sudo systemctl start jenkins
Docker Setup
Add User to Docker Group:
Add your user to the Docker group:
sudo usermod -aG docker $USER
Verify User Group Addition:
Verify that your user has been added to the Docker group:
groups $USER
Fix Docker Permission Errors:
- If you encounter permission errors, restart your machine or log out and log back in.
Create a Dockerfile:
Create a
Dockerfilein your project directory. Example:FROM openjdk:11 COPY . /app WORKDIR /app RUN ./mvnw package CMD ["java", "-jar", "target/your-app.jar"]
Build Docker Image:
Build your Docker image:
docker build -t your-app .
List Docker Images:
List your Docker images to verify the build:
docker images
Run Docker Container:
Run your Docker container:
docker run -p 8080:8080 your-app
List Running Containers:
List running containers to verify your application is running:
docker ps
Set Up Inbound Rules: Add specific ports to your instance for accessing your application via browser (refer to Setting up inbound rules).
Jenkins Setup
Access Jenkins: Visit
<Your_Public_IP:8080>in your browser.Unlock Jenkins: Use the admin password found in the location specified in the Jenkins setup page.
Set Up Jenkins: Follow the instructions in the Jenkins setup wizard to complete the setup.
Create a Freestyle Job: Create your first Jenkins job by referring to the Jenkins documentation on First Freestyle Job.
GitHub Webhook Integration
Create a Webhook in GitHub: Set up a webhook in your GitHub repository by following the instructions in How to create a Webhook.
Configure Webhook:
Payload URL:
<Jenkins_URL:port/github-webhook/>Select Events: Choose the events that should trigger the webhook.
Add Webhook: Click on the “Add webhook” button and refresh the page to confirm activation.
Integrate Webhook with Jenkins Job: Follow the steps in the Jenkins documentation to integrate the webhook with your Jenkins job.
Test Integration: Make changes to any file in your GitHub repo, commit the changes, and verify that Jenkins triggers the job automatically.
Access Application: Use
<Your_Public_IP>:Portspecified in your application to verify deployment.
Thankyou for reading !!!!!




