This document provides a step-by-step guide to set up an end-to-end Jenkins pipeline for a Java-based Spring Boot application. The pipeline integrates code quality checks with SonarQube, containerization with Docker, deployments with Helm and Kubernetes, and GitOps-based continuous delivery using Argo CD.
-
Java application code hosted in a Git repository
-
An EC2 server with the following installed:
- Jenkins
- SonarQube
- Docker
- Maven
-
A local Minikube cluster with:
- Kubernetes
- Helm
- Argo CD
sudo apt update
sudo apt install openjdk-11-jdk -y
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
sudo apt install jenkins -y
sudo systemctl start jenkins
sudo systemctl enable jenkinsAccess Jenkins at: http://<EC2-Public-IP>:8080
sudo apt update && sudo apt install unzip -y
adduser sonarqube
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-10.4.1.88267.zip
unzip sonarqube-10.4.1.88267.zip
sudo mv sonarqube-10.4.1.88267 /opt/sonarqube
sudo chown -R sonarqube:sonarqube /opt/sonarqube
cd /opt/sonarqube/bin/linux-x86-64
./sonar.sh startAccess SonarQube at: http://<EC2-Public-IP>:9000
- Git Plugin
- Maven Integration Plugin
- Pipeline Plugin
- SonarQube Scanner Plugin
- Kubernetes Continuous Deploy Plugin
- Configure Maven under
Manage Jenkins > Global Tool Configuration. - Configure SonarQube server under
Manage Jenkins > Configure Systemwith the SonarQube server URL and token. - Add Docker and Kubernetes credentials in Jenkins credentials.
In Jenkins, create a new pipeline job and connect it to the application Git repository. Add a Jenkinsfile in the repository with the following stages:
- Checkout Code – Fetch source from Git.
- Build Application – Use Maven to compile and package.
- Run Tests – Execute unit tests with JUnit/Mockito.
- SonarQube Analysis – Static code analysis.
- Package Application – Generate JAR file.
- Docker Build & Push – Build and push image to Docker Hub.
- Deploy to Test (Helm) – Deploy to Minikube using Helm.
- Run Acceptance Tests – Validate deployment.
- Promote to Production (Argo CD) – Sync to production namespace.
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yamlExpose Argo CD server:
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "NodePort"}}'
kubectl get svc -n argocdAccess at: http://<Minikube-IP>:<NodePort>
- Add repository containing Helm charts and manifests.
- Create an Argo CD application pointing to the repo and target namespace.
- Generate Argo CD API token.
- Add token to Jenkins credentials.
- Update Jenkinsfile to include Argo CD deployment stage using API calls or CLI.
-
Trigger the Jenkins pipeline manually or via a Git webhook.
-
Jenkins will:
- Build the app with Maven.
- Run tests and SonarQube analysis.
- Build and push Docker image.
- Deploy to Kubernetes test environment using Helm.
- Sync production environment with Argo CD.
This guide sets up an end-to-end CI/CD pipeline for a Java Spring Boot application using Jenkins, SonarQube, Docker, Helm, Kubernetes, and Argo CD. Jenkins and SonarQube run on an EC2 server, while Minikube hosts Kubernetes and Argo CD locally. This setup ensures automated builds, testing, code quality checks, containerization, and GitOps-driven deployments.
Users can replicate this setup on their own infrastructure by following the steps above.
