CI/CD Using Jenkins, GitHub Webhooks, and Deployment on Nginx/Apache

"Hello, I'm Kiran Pawar, a passionate Cloud and Devops Engineer with a strong background in cloud automation, configuration, and deployment. My journey in the world of technology has been a thrilling adventure, where I've had the privilege to work with cutting-edge tools and practices.
๐ As a DevOps Engineer:
I specialize in automating, configuring, and deploying instances in cloud environments and data centers. My expertise extends to DevOps, GitOps, CI/CD pipeline management, HashiCorp Terraform, and containerization. I'm proficient in AWS and Linux/Unix administration, ensuring robust infrastructure and application performance.
๐ง My Tech Stack:
Front-end skills: HTML, CSS, SCSS, Tailwind CSS, Bootstrap, React, Material-UI, JavaScript DevOps toolbox: GIT, OWASP,Nexus,Trivy, Github, Gitlab, Terraform, Ansible, Docker, Kubernetes, Helm, Jenkins, Prometheus, Grafana, Argo CD, AWS EKS.
๐ My Cloud Expertise:
I have hands-on experience managing AWS services, including EC2, S3, EBS, VPC, ELB, RDS, IAM, Route53, and more.
๐ Networking and Security:
My skills include managing networking concepts such as TCP/IP protocols, security policies, and subnet interfacing. I have a strong understanding of infrastructure and networking, covering topics like firewalls, IP addressing, DNS, and more.
๐ก What Sets Me Apart:
I bring a positive attitude, a strong work ethic, and a collaborative spirit to every project. I'm a self-starter, a fast learner, and an effective team player with strong interpersonal skills. In addition to my DevOps skills, I've developed shell scripts (Bash) for automating tasks and have proficiency in Python scripting. My ability to communicate and manage projects, along with a track record of resolving client issues, adds value to every team I work with. If you're looking for a DevOps engineer who is also well-versed in front-end technologies, feel free to connect with me. Let's explore new possibilities and create exceptional technical solutions together!"
Continuous Integration and Continuous Deployment (CI/CD) pipelines ensure automated code testing and deployment, enhancing the development process. This guide walks you through setting up a CI/CD pipeline using Jenkins, GitHub Webhooks, and deploying to an Nginx or Apache server.
Step 1: Create and Update an EC2 Server
Launch an EC2 server from your AWS Management Console.
Update the server packages by running the following commands:
sudo apt update -y
Step 2: Install Nginx
- Install the Nginx web server:
sudo apt install nginx -y
- Navigate to the Nginx HTML folder and replace the
index.htmlfile to display your webpage:
cd /var/www/html
Replace or add your index.html file here.
Step 3: Install Jenkins
Prerequisite: Install Java
Jenkins requires Java to run. Install it using:
sudo apt install jdk-17-jre -y
Install Jenkins
- Add the Jenkins key and repository:
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
- Update the server and install Jenkins:
sudo apt-get update
sudo apt-get install jenkins -y
Step 4: Configure GitHub Webhooks
Go to your GitHub repository settings.
Under Webhooks, add a new webhook.
Enter the Jenkins webhook URL:
http://<EC2-Public-IP>:8080/github-webhook/
Replace <EC2-Public-IP> with your EC2 server's public IP address. This ensures the Jenkins pipeline is triggered on every new commit.
Step 5: Create a Jenkins Freestyle Job
Log in to Jenkins.
Create a new Freestyle Project.
Configure the Git repository URL for the project. For example:
https://github.com/imkiran13/Irrigation.git
- Enable the GitHub hook trigger option in Jenkins.
Step 6: Configure Deployment to Nginx
- Add a build step to copy project files to the Nginx HTML folder:
cp -r * /var/www/html/
- Run the pipeline. If you encounter a "Permission Denied" error, proceed to the next step.
Step 7: Resolve Permission Denied Error
- Grant the Jenkins user permission to access the Nginx folder:
sudo chown -R jenkins:jenkins /var/www/html/
- Rerun the pipeline.
Step 8: Verify the Deployment
Open your browser.
Enter your EC2 server's public IP address.
Verify that your deployed webpage is displayed.
Conclusion
You have successfully set up a CI/CD pipeline using Jenkins and GitHub Webhooks, and deployed the application to an Nginx server. This process ensures seamless integration and automated deployment for your web applications.
Feel free to modify this pipeline to suit your project's specific requirements!
