Complete Jenkins CI/CD Project
Let's make a beautiful CI/CD Pipeline for Node JS Application 😍
Task-01
I have forked the repository: https://github.com/surajc5/node-todo-cicd.git for the
"node-todo-cicd
" project
Create an AWS EC2 instance
- Install Jenkins on AWS EC2 instance
1. sudo apt-get update
#install java
2. sudo apt install openjdk-17-jre
3. curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee \
/usr/share/keyrings/jenkins-keyring.asc > /dev/null
4. 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
# Again update the system
5. sudo apt-get update
# Install Jenkins
6 . sudo apt-get install jenkins
- Open port 8080 from AWS Console & Setup Jenkins 🚀 Click on Create a job.
- 🚀 Create Freestyle Project Name
Node-todo-app
🚀 Provide Description and GitHub URL.
Select GitHub hook trigger for GITScm polling
Configure GitHub Webhook
Open your GitHub repository in your browser.
Go to the repositories
Settings
" tab.Select
Webhooks
from the left-hand menu.Click on the
Add webhook
button.In the "Payload URL" field, enter the Jenkins server URL.
For "Content type," choose "application/JSON."
Select the events that you want to trigger in the webhook. The most common event is "push," which triggers when code is pushed to the repository.
Click "Add webhook" to save the webhook configuration.
After saving Refresh the page until the green ✅tick comes
Then come to the Jenkins page🚀 Click on Build Steps and select Execute Shell.
🚀 Click the Save button and the job will appear on the dashboard screen.
💡Before must install docker and grant access.💡Before must give access to Jenkin to access docker.
# install docker
sudo apt install docker.io
#grant acess
sudo usermod -aG docker $USER
sudo usermode -aG docker jenkins
#reboot the system
sudo reboot
Access your app through Jenkins URL
💥Boom node-todo-cicd project has deployed successfully💥
Lets changes on GitHub, and then it automatically triggers and builds the job and deploys the project.
The automatic build section job will fail because this port already running how can allocate the same port again to stop the removal process? Again try with changes.
docker kill <container-name> docker rm <container-name>
-
💥Boom node-todo-cicd project has deployed successfully through WebHook💥
Task-02
In the Execute shell run the application using Docker compose
💡Must install docker-compose
#stop previos running container
docker kill <container_name> && docker rm <container_name>
#install docker compose
sudo apt install docker-compose
🚀 Click on save and build now.
💥Boom project has deployed successfully with docker-compose💥
Thank you for reading. Happy Learning!!!😊
Subscribe to my newsletter
Read articles from Suraj barik directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Suraj barik
Suraj barik
I'm Suraj Barik Aspiring DevOps Engineer with Hands-on experience in Automating,Shell Scripting, Supporting in AWS, management, CI/CD, and DevOps processes.