Check out the website: Webapp Maven Application
- Project Description
Hi 👋, This Project is about Maven Webapp Deployment by using the Continuous Integration and Continuous Deployment Infrastructure settled on the Jenkins Automation Server!.We are going to Build,Test and Deploy the Application on the Deployment Server which can be further modified by Anyone by forking the repository and make the changes to it then after raise the Pull Request which will be inspected to be merged after being merged(Steps Described Ahead in additon to do the changes to the Project) we will be able to see the Jenkins Job be triggered up by the github webhook In order to actually montior the Jenkins Job visit Click Here Login by Credentials given as follows -
Username - guest1.Click on the Application Deployment Job
Password - IamGuest
As the Job Completes It triggers the Continuous Deployment Job
2.Click on the Continuous Deployment JobEventually,This Job Deploys the Application on the Tomcat Container Deployment Server
This application consists of the following components:- A single-AWS-Linux-instance used as a Jenkins Automation Server to Build,Test and Deploy the Applicaion
- A single-AWS-Linux-instance used as a Ansible App Deployment Server
- A single-AWS-Linux-instance used as a Tomcat-Deployment Server where our Maven App will be Deployed
- Tools and Technology
- Stages
The project includes three Stages for Maven Application Deployment. The modules are Building and Testing, shiping the artifact on Dockerhub and Deployment on Tomcat Docker Container on the Deployment Sever.
- Building the Artifact and Testing Automatically by Maven
- Docker image Creation:
Again,Jenkins holds the charge and by using the plugin called publish over ssh the webapp artifact is sent to the ansible server where it is built as a Docker image by using the Dockerfile and the meaningfull ansible playbook which is triggerd by the Publish over ssh plugin as the webapp artifact is Successfully Publish over the ssh to the ansible Application Deployment Server!
First stage is about creation of Artifact and Testing Automatically by maven.Basically,Jenkins hold the charge and starts our Continuous Integration Process(know more about CI and CD here Know more) of building and Testing the application by Its plugin called Maven Integration Plugin which provides us the ease of Building the application and Testing it!
- Docker image Creation:
- Shipping to the Dockerhub
- Tagging and Pushing
By using the same Ansible Playbook responsible for the creation of the Docker Image further Modules does the tagging and Pushing to the DockerHub!
Shipping is the process of pushing docker image to the repo where it is stored for the further use at any enviroment despite of the configuration mess.Here,Dockerhub is used as the service for the having the docker images
- Tagging and Pushing
- Deploying To The Tomcat Container on the Host Server
- Process of Deployment:
Ansible Playbook lying on the Ansible Application Deployment Server is triggered by our Automation Server Jenkins and Ansible playbook starts the Process of Deploying the Application on The Tomcat Application Deployment Server by pulling the Application Image on the Deployment server and Creates the Container out of it with proper configuration and removes any older version of the image,removes any older running tomcat container with the older configuration and Deploys Fresh Application on the Server.Basically,If the Application does not exist on the Deployment server then the our playbook ignores the error caused by it and goes through the futher process defined.
Deloyment is done via the Approach of the Continuous Deployment where no Human Intervention is Required to make the configurations Ready to deploy the Application our Automated Pipeline reduces human efforts at massive extent.
- Process of Deployment:
- Building the Artifact and Testing Automatically by Maven
An elastic IP is allocated to the Deployment Server and Jenkins Automation Server so NO Worries about the IP being changed even after the unfortunate restart or shutdown! Visit the address with ease which are provided at required places!
- Fork the project using the gray
Fork
button in the top right of this page. - Make any changes in your forked repository.
- On this repo, click
Pull Requests
(which is the third option at the top of this page after the optionsCode
andIssues
) and raise a Pull Request by clicking the greenNew Pull Request
button and selecting your fork from the right dropdown field.
You can ask questions by raising an issue.
-
Click on the green
Code
button, then either the HTTPS or SSH option and, click the icon to copy the URL. Now you have a copy of the project. Thus, you can play around with it locally on your computer. -
Run the following commands into a terminal window (Command Prompt, Powershell, Terminal, Bash, ZSH). Do this to download the forked copy of this repository to your computer.
git clone https://github.com/Tanish-Mishra/Maven-App-Deployment-Using-CI-CD.git
- Switch to the cloned folder. You can paste this command into the same terminal window.
cd Maven-App-Deployment-Using-CI-CD
- Make a new branch. Your username would make a good branch because it's unique.
git checkout -b <name-of-new-branch>
-
Open the
/webapp/src/main/webapp/index.jsp
file -
Do changes.
It can be a simple HTML element addition
-
Stage your changes.
git add .
- Commit the changes.
git commit -m "YOUR-NAME"
- Check the status of your repository.
git status
- The response should be like this:
On branch <name-of-your-branch>
nothing to commit, working tree clean
- Pushing your repository to GitHub.
git push origin <name-of-your-branch>
or
git branch -M main
git push -u origin main
If you get an error message like the one below, you probably forgot to fork the repository before cloning it. It is best to start over and fork the project repository first.
ERROR: Permission to Tanish-Mishra/Maven-App-Deployment-Using-CI-CD denied to <your-github-username>.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
-
On the GitHub website, navigate to your forked repo - on the top of the files section, you'll notice a new section containing a
Compare & Pull Request
button! -
Click on that button, this will load a new page, comparing the local branch in your forked repository against the main branch in the Tanish-Mishra Maven-App-Deployment-Using-CI-CD repository. Accept the default values in the dropdown boxes and click the green
Create Pull Request
button. After creating the PR (Pull Request). Note: A pull request allows us to merge your changes with the original project repo. -
Your pull request will be reviewed and then eventually merged.
Hurray! You successfully have made your Changes and also pushed them; Now you may,visit Click Here to see your changes! 🎉