Day 81: DevOps Project -2 Web-APP Deploying using Jenkins Declarative Syntax
Day 81: #90DaysOfDevOpsChallenge
Dear Learners, In my Previous learning I have used Various DevOps Tools,In today's article we will explain the Project 2 Web-APP with the help of Jenkins Declarative Pipeline.
Project Description:
The Project is about automating the deployment process of a web application using Jenkins and its declarative syntax. The pipeline includes stages like building, testing and Deploying to a staging environment. It also includes running acceptance tests and deploying to production if all tests pass.
Pre-requisites
1 Create an EC2 instance in the AWS management console with the required storage.
2 Install jenkins and Docker in the EC2 instance.
Please go-through my last Project-1 Day 80 to find the more details here is the Link:-
Project Steps:
1. Navigate to the Jenkins dashboard and go to new item. Then select Pipeline and create the project.
Navigate to the Jenkins dashboard and go to new item. Then select Pipeline and create the project Diagram.
Navigate to the Jenkins dashboard and go to new item. Then select Pipeline and create the project Diagram
2. In the genereal section provide the project description and also the GitHub project URL.
In the genereal section provide the project description and also the GitHub project URL Diagram.
3. In the build trigger section select the GitHub webhook trigger option.
Ensure the Webhook is configures in GitHub.
In the build trigger section select the GitHub webhook trigger option Diagram.
4. Ensure the project has a Docker file in GitHub.
Ensure the project has a Docker file in GitHub Diagram.
5. Write the declarative pipeline code which is a groovy syntax code to set up the project pipeline.
Agent:- Agents is a different servers that are linked to the master Jenkins server. An agent can be set up in the pipeline to run the pipelines in different agents. In this project, we are with the default agent.
Stages:- Stages contain different steps to be executed as part of the project pipeline.
In this project we have the 3 stages:
Code:- The code stage pulls the code from GitHub to build and execute the Pipeline in further steps.
Build and Test:- The stage builds the image of the app code from the docker file.
Run:- This stage runs the Container in the server and makes the application up.
pipeline {
agent any
stages{
stage('Code'){
steps{
git url: 'https://github.com/Maninderit/node-todo-cicd1.git', branch: 'master'
}
}
stage('Build and Test'){
steps{
echo "$USER"
sh 'docker build -t webapp .'
echo "build and ttest completed"
}
}
stage('Run'){
steps{
sh "docker run -d -p 8000:8000 webapp"
}
}
}
}
1 . After writing the detailed pipeline groovy script in the project configuration apply and save the Project.
After writing the detailed pipeline groovy script in the project configuration apply and save the Project Diagram.
Navigate to the project and click on Build Now to execute the project Diagram.
2. Navigate to the project and click on Build Now to execute the project.
Navigate to the project and click on Build Now to execute the project Diagram.
3. We can see the successful console output and the stages that are completed in its stage executions as shown in the above and below screenshots.
We can see the successful console output and the stages that are completed in its stage executions as shown in the above and below screenshots Diagram
We can see the successful console output and the stages that are completed in its stage executions as shown in the above and below screenshots Diagram
We can see the successful console output and the stages that are completed in its stage executions as shown in the above and below screenshots Diagram
We can see the successful console output and the stages that are completed in its stage executions as shown in the above and below screenshots Diagram
4. Ensure to open the port 8000 in the security group associated with the EC2 instance.
Ensure to open the port 8000 in the security group associated with the EC2 instance Diagram.
5 . Finally, navigate to the web-app URL and we can see the application is up and Running.
Finally, navigate to the web-app URL and we can see the application is up and Running Diagram.
Hope I helped you in understanding the concept in a better way!!
Happy Learning
Next Topic:
Day 82: we will explore and one step forward hosting a static website using an AWS S3 bucket.