Skip to main content

A Complete CI/CD Pipeline

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

Popular posts from this blog

Terraform for AWS: Step-by-Step Infrastructure Automation That Actually Works

How I Use Terraform to Provision and Manage AWS Infrastructure Efficiently Infrastructure as Code (IaC) has become a critical part of modern cloud operations, and Terraform is one of the most popular tools for automating cloud infrastructure deployment. In this article, I'll share how I use Terraform to build and manage AWS resources such as Virtual Private Clouds (VPCs), EC2 instances, Application Load Balancers (ALBs), and Auto Scaling Groups. Building AWS Infrastructure with Terraform My infrastructure deployment process begins by defining all AWS resources as code. This approach ensures consistency, repeatability, and easier management across multiple environments. The first step is creating a secure network architecture using a VPC. Within the VPC, I configure public and private subnets, route tables, internet gateways, and other networking components required for application deployment. Once the networking layer is ready, I deploy EC2 instances inside private su...

Master Linux Administration for DevOps: Powerful Commands, Troubleshooting Tips & Best Practices

Linux administration is one of the most important skills for anyone working in DevOps. From application servers and CI/CD platforms to containers and cloud infrastructure, Linux-based systems are widely used in modern technology environments. In my day-to-day DevOps activities, I regularly work with Linux commands to manage files, monitor processes, troubleshoot services, investigate network problems, analyze logs, and resolve production issues. This guide covers essential Linux administration concepts and commands that are useful for DevOps engineers, along with practical examples of how they can be applied during everyday troubleshooting. 1. Understanding Linux File Permissions Linux uses a permission system to control access to files and directories. The three basic permissions are: Read (r) – Allows a user to view the contents of a file or directory. Write (w) – Allows modifications to a file or directory. Execute (x) – Allows a file to be executed or a director...