The Dec2Hex_Java_Project is a Java-based application that converts decimal values into their hexadecimal equivalents. This project includes a fully automated CI/CD pipeline using Jenkins, SonarQube, JaCoCo, and Docker. It demonstrates modern software engineering practices, including automated builds, testing, and code quality analysis.
Converts decimal numbers to hexadecimal.
Automated unit testing using JUnit.
Code quality analysis with SonarQube.
Test coverage reporting using JaCoCo.
Fully containerized using Docker for portability.
Programming Language: Java
Build System: Jenkins
Static Analysis Tool: SonarQube
Test Coverage Tool: JaCoCo
Containerization: Docker
-
Docker: Installed and running.
-
Java 17: Ensure Java 17 or higher is available.
-
SonarQube Server: Hosted locally or remotely.
-
Jenkins Server: Hosted locally or remotely.
- Clone the Repository
git clone https://github.com/FreemanBoss/Dec2Hex_Java_Project.git
cd Dec2Hex_Java_Project
- Docker Setup
Run the following to start Jenkins and SonarQube:
docker run -d --name jenkins -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts
docker run -d --name sonarqube -p 9000:9000 sonarqube
- Configure Jenkins
Install required plugins: SonarQube Scanner, Git, JUnit, and Pipeline.
Add your SonarQube server URL under "Manage Jenkins > Configure System".
Create a pipeline job pointing to this repository.
- Configure SonarQube
Log in to your SonarQube instance at http://:9000.
Create a new project and generate a token.
Add the token to Jenkins under "Manage Jenkins > Credentials".
- Run the Pipeline
Trigger the Jenkins pipeline to automate the build, test, and analysis process.
Check the SonarQube dashboard for detailed analysis and code quality metrics.
How It Works
-
Compilation: Jenkins compiles the Dec2Hex.java program.
-
Testing: Executes JUnit tests to ensure accuracy and handle edge cases.
-
Code Quality: SonarQube analyzes the code for bugs, vulnerabilities, and maintainability.
-
Coverage Reports: JaCoCo generates test coverage reports.
-
Artifact Generation: The pipeline creates coverage reports in the target/site/jacoco/ directory.
Challenges and Scaling
Server Scaling on DigitalOcean:
Initial Setup:
2GB RAM, 2 vCPUs, 60GB SSD disk.
Midway Upgrade:
Upgraded to 4GB RAM, 2 vCPUs, 80GB SSD disk.
Final Configuration:
8GB RAM, 4 vCPUs, 160GB SSD disk for smooth performance during coverage reporting.
Test Cases
The project includes five key test cases in Dec2HexTest.java to handle:
-
Valid decimal input.
-
Negative input (error handling).
-
Zero input.
-
Non-integer input (error handling).
-
No input provided (error handling).
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Contributors
- FreemanBoss
For questions, feedback, or contributions, please feel free to reach out or create an issue in the repository.