This project demonstrates a manual buildโstageโdeploy pipeline for a Java-based Web Calculator App, progressively enhanced across three versions:
| Version | Features Included | WAR File Name | Description |
|---|---|---|---|
| v0.0.1 | Addition only | webapp-add-0.0.1.war |
Basic calculator with addition feature |
| v0.0.2 | Addition + Subtraction | webapp-add-sub-0.0.2.war |
Enhanced version with subtraction functionality |
| v0.0.3 | Addition + Subtraction + Multiplication | webapp-add-sub-mul-0.0.3.war |
Final version with multiplication added |
| Server | Purpose | Key Ports | Tools Installed |
|---|---|---|---|
| Build Server | Compiles and packages the code using Maven | 22 | OpenJDK 17, Maven, Git |
| Nexus Server (Staging) | Stores the .war artifacts |
22, 8081 | OpenJDK 17, Nexus Repository 3 |
| Deploy Server | Hosts the final app via Tomcat | 22, 8080 | OpenJDK 17, Apache Tomcat 9 |
# 1๏ธโฃ Hostname setup
sudo hostnamectl set-hostname build
sudo init 6
# 2๏ธโฃ System update & Java installation
sudo apt -y update
sudo apt install openjdk-17-jre-headless -y
# 3๏ธโฃ Install Maven
sudo apt install maven -y
java -version
mvn -version
# 4๏ธโฃ Clone the repository
git clone https://github.com/mrtechreddy/Java-Web-Calculator-App.git
cd Java-Web-Calculator-App/
# 5๏ธโฃ Validate & package source
mvn validate
mvn clean package
# 6๏ธโฃ Verify WAR files in target/
cd target/
ls
Each time a feature is added, the app is rebuilt with a version tag:
| Step | Feature Added | Command | Output Artifact |
|---|---|---|---|
| 1 | Addition | mvn clean package |
webapp-add-0.0.1.war |
| 2 | Addition + Subtraction | Update code โ mvn clean package |
webapp-add-sub-0.0.2.war |
| 3 | Addition + Sub + Mul | Update code โ mvn clean package |
webapp-add-sub-mul-0.0.3.war |
Update your pom.xml or /etc/maven/settings.xml:
<distributionManagement>
<repository>
<id>Java-Cal-App</id>
<url>http://51.21.200.175:8081/repository/Java-Cal-App/</url>
</repository>
</distributionManagement>Then push build artifacts:
mvn deploy
sudo hostnamectl set-hostname nexus
sudo init 6
sudo apt -y update
sudo apt install openjdk-17-jre-headless -y
# Download and extract Nexus
wget https://download.sonatype.com/nexus/3/nexus-3.85.0-03-linux-x86_64.tar.gz
tar -xvzf nexus-3.85.0-03-linux-x86_64.tar.gz
cd nexus-3.85.0-03/bin/
# Start Nexus service
./nexus start
sudo apt install net-tools -y
sudo netstat -ntpl-
URL:
http://51.21.200.175:8081 -
Login:
- Username:
admin - Password:
/home/ubuntu/sonatype-work/nexus3/admin.password
- Username:
Create a hosted Maven repository named Java-Cal-App.
After each deployment:
| Version | Artifact Path |
|---|---|
| 0.0.1 | /repository/Java-Cal-App/com/web/cal/webapp-add/0.0.1/webapp-add-0.0.1.war |
| 0.0.2 | /repository/Java-Cal-App/com/web/cal/webapp-add-sub/0.0.2/webapp-add-sub-0.0.2.war |
| 0.0.3 | /repository/Java-Cal-App/com/web/cal/webapp-add-sub-mul/0.0.3/webapp-add-sub-mul-0.0.3.war |
sudo hostnamectl set-hostname deploy
sudo init 6
sudo apt -y update
sudo apt install openjdk-17-jre-headless -y
# Download Apache Tomcat 9
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.111/bin/apache-tomcat-9.0.111.tar.gz
tar -xvzf apache-tomcat-9.0.111.tar.gz
cd apache-tomcat-9.0.111/
# Configure admin access
vi conf/tomcat-users.xml
# Add:
# <user username="admin" password="admin123" roles="manager-gui,admin-gui"/>
# Remove access restrictions
sudo vi ./webapps/manager/META-INF/context.xml
sudo vi ./webapps/host-manager/META-INF/context.xml
# Comment out or remove <Valve ...> line
# Start Tomcat
./bin/startup.sh
cd apache-tomcat-9.0.111/webapps/
wget http://<NEXUS-IP>:8081/repository/Java-Cal-App/com/web/cal/webapp-add/0.0.1/webapp-add-0.0.1.warAccess โ http://<DEPLOY-IP>:8080/webapp-add
wget http://<NEXUS-IP>:8081/repository/Java-Cal-App/com/web/cal/webapp-add-sub/0.0.2/webapp-add-sub-0.0.2.warAccess โ http://<DEPLOY-IP>:8080/webapp-add-sub
wget http://<NEXUS-IP>:8081/repository/Java-Cal-App/com/web/cal/webapp-add-sub-mul/0.0.3/webapp-add-sub-mul-0.0.3.warAccess โ http://<DEPLOY-IP>:8080/webapp-add-sub-mul
Restart Tomcat after each deployment:
./bin/shutdown.sh
./bin/startup.sh| Stage | Output | Verification |
|---|---|---|
| Build | .war in /target |
ls target/ |
| Stage | Artifact in Nexus | Nexus GUI โ browse Java-Cal-App |
| Deploy | App running in browser | Access via Tomcat on port 8080 |
| Issue | Cause | Fix |
|---|---|---|
| Nexus not reachable | Service not started | cd nexus-3.85.0-03/bin && ./nexus start |
| Maven deploy fails | Wrong repo credentials | Check <servers> in settings.xml |
| Tomcat 403 error | Context.xml restricted | Comment out <Valve> line |
| WAR not visible | Cached deployment | Clear /webapps and redeploy |
- Java 17
- Apache Maven 3
- Sonatype Nexus 3
- Apache Tomcat 9
- Ubuntu 22.04 LTS (AWS EC2)
Sivaiah Jagadapi Power BI Developer | DevOps Learner | Cloud Automation Explorer ๐ Hyderabad, India ๐ Glintsoft Infotech Pvt Ltd ๐ง [email protected]
Source Code v1 โ Build (Maven) โ WAR v0.0.1 โ Nexus Repo โ Tomcat Deploy (Addition)
โ
Source Code v2 โ Build (Maven) โ WAR v0.0.2 โ Nexus Repo โ Tomcat Deploy (Add + Sub)
โ
Source Code v3 โ Build (Maven) โ WAR v0.0.3 โ Nexus Repo โ Tomcat Deploy (Add + Sub + Mul)
โ Final Outcome: A fully working 3-tier manual CI/CD pipeline demonstrating Java web app build, artifact staging in Nexus, and deployment to Tomcat โ versioned incrementally as new calculator features are added.
---