Project : Jenkins Declarative Pipeline: From Code to Production - Effortless Web App Deployment
Project Description: Automate the deployment process of a web application using Jenkins and its declarative syntax. This pipeline includes stages for building, testing, and deploying to a staging environment. It also performs acceptance tests and, upon success, deploys to production. Easy and efficient CI/CD from code to production.
Prerequisite:
- EC2 Instance (Ubuntu) on AWS.

- Jenkins installed on the EC2 Instance.

If you encounter any issues during the installation of Jenkins, you can refer to the following website for guidance: https://www.jenkins.io/doc/book/installing/linux/
- Docker and Docker-compose installed on the EC2 Instance.

If Docker and Docker-compose are not already installed, you can do so by executing the following command:
sudo apt-get install docker.io docker-compose
Add your Jenkins user to the Docker group by running the following commands:
sudo usermod -aG docker jenkins
sudo service jenkins restart
Now Let's get started.
Step - 1 : Goto Jenkins dashboard and click on "New Item "

Step - 2 : Name your project and choose the pipeline option.

Step - 3 : Use the provided pipeline script to define stages for checkout, testing, building, and deployment.

pipeline {
agent any
stages {
stage('checkout') {
steps {
git branch : 'main',url:'https://github.com/patelajay745/react_django_demo_app.git'
}
}
stage('Test') {
steps {
echo 'testing'
}
}
stage('Build') {
steps {
sh 'docker build --no-cache -t demo_app .'
}
}
stage('Deploy') {
steps {
sh "docker run -p 8001:8001 -d demo_app"
}
}
}
}
Here I have used this repo for the project : https://github.com/patelajay745/react_django_demo_app
Step - 4 : Save the pipeline configuration.
Step - 5 : Click "Build Now" to initiate the pipeline and monitor progress in "Stage View."

Once all stages succeed, access your app at :

Congratulations! You've successfully implemented Jenkins Declarative CI/CD pipeline. If you have any questions or face any issues, feel free to ask in the comments. Happy Deploying!



