Complete CI/CD Pipeline Using GitHub, Jenkins, Maven, SonarQube, Nexus, and Docker
A well-designed CI/CD pipeline plays a critical role in modern DevOps practices by automating software delivery, improving code quality, and reducing deployment risks. In this article, I will explain how I build an automated CI/CD pipeline using GitHub, Jenkins, Maven, SonarQube, Nexus Repository, Docker, and Docker Hub.
Source Code Management with GitHub
The CI/CD workflow begins with storing the application source code in GitHub. Developers regularly push code changes or create pull requests to collaborate on features and bug fixes.
Whenever new code is pushed to the repository, GitHub triggers Jenkins automatically through a webhook. This integration helps start the CI/CD pipeline without manual intervention.
Code Checkout Stage in Jenkins
The first stage of the pipeline is the checkout process. Jenkins connects to the GitHub repository and pulls the latest version of the source code.
This ensures the pipeline always works with updated code changes from the development team.
Build Automation Using Maven
After the checkout stage, Jenkins starts the build process using Apache Maven. Maven compiles the source code, manages project dependencies, and executes unit tests.
If any compilation issue or failed test case is detected, Jenkins immediately stops the pipeline. This prevents unstable or broken code from moving to the next stages.
Code Quality Analysis with SonarQube
Once the build process is successful, the pipeline performs static code analysis using SonarQube.
SonarQube scans the application for:
- Code smells
- Security vulnerabilities
- Bugs and reliability issues
- Duplicate code
- Maintainability problems
I also configure a quality gate in SonarQube to enforce coding standards. If the code does not meet the required quality threshold, Jenkins automatically fails the pipeline.
This approach helps maintain clean, secure, and production-ready code.
Artifact Management with Nexus Repository
After passing the quality checks, Maven packages the application into a deployable artifact such as a JAR or WAR file.
The generated artifact is then uploaded to Nexus Repository Manager, which acts as a centralized artifact storage system.
Nexus provides several advantages, including:
- Centralized artifact management
- Version control support
- Easy rollback capabilities
- Secure artifact storage
Docker Image Creation and Containerization
The next stage in the CI/CD pipeline focuses on containerization using Docker.
Jenkins builds a Docker image using the artifact stored in Nexus Repository. Each Docker image is tagged with a unique build number or version to maintain deployment consistency and release tracking.
Push Docker Images to Docker Hub
Once the Docker image is successfully built, Jenkins pushes the image to Docker Hub.
Docker Hub serves as the container image registry, making it easier to store, manage, and distribute Docker images across multiple environments.
Automated Deployment Process
In the deployment stage, Jenkins pulls the required Docker image from Docker Hub and deploys it to the target environment.
The target infrastructure may include:
- Docker servers
- Kubernetes clusters
- Cloud-based container platforms
For better release management, I usually follow a Dev → Test → Production deployment strategy.
Common CI/CD Pipeline Failures and Solutions
Maven Build Failure
One common issue in CI/CD pipelines is Maven build failure caused by missing dependencies or failed unit tests.
I typically resolve this issue by:
- Reviewing Jenkins console logs
- Validating dependency versions
- Fixing failed test cases
SonarQube Quality Gate Failure
Sometimes the pipeline fails because the code does not satisfy SonarQube quality gate conditions.
This usually happens due to:
- Security vulnerabilities
- Code smells
- High code duplication
- Poor maintainability
These issues should be fixed before merging the code into the main branch.
Nexus Upload Failure
Nexus artifact upload failures often occur because of incorrect credentials or insufficient storage space.
I solve these issues by:
- Verifying repository credentials
- Checking repository permissions
- Cleaning old artifacts
Docker Build Failure
Docker image creation may fail because of incorrect Dockerfile instructions or dependency issues.
To avoid these problems, I:
- Test Docker builds locally
- Keep Dockerfiles simple and optimized
- Use lightweight base images
Deployment Failure
Deployment issues are commonly caused by port conflicts or incorrect environment configurations.
I handle these problems by:
- Using environment variables
- Implementing proper health checks
- Standardizing deployment configurations
Conclusion
This CI/CD pipeline architecture helps automate the entire software delivery lifecycle, from code integration to deployment.
By integrating GitHub, Jenkins, Maven, SonarQube, Nexus Repository, Docker, and Docker Hub, organizations can achieve faster deployments, improved code quality, secure artifact management, and highly reliable application releases with minimal manual effort.

Comments
Post a Comment