Key DevOps Concepts Implemented
CI (Continuous Integration)
• Automated build
• Automated testing
CD (Continuous Delivery)
• Automated packaging
• Automated deployment
Quality Gate
• Prevents bad code deployment
Containerization
• Docker image creation
Orchestration
• Kubernetes deployment
Complete Enterprise Architecture Flow
Developer
↓
GitHub
↓
Jenkins
↓
Build
↓
Test
↓
SonarQube
↓
AI Analysis (OpenAI)
↓
AI Risk Decision
↓
Nexus
↓
Docker
↓
DockerHub
↓
Helm
↓
Kubernetes
↓
Production
Pipeline Execution Flow Explanation
Stage 1 — Checkout
Pulls code from GitHub
Stage 2 — Build
Compiles application
Stage 3 — Test
Runs unit tests
Stage 4 — Quality Gate
Validates code quality
Stops pipeline if quality is poor
Stage 5 — Package
Creates JAR file
Stage 6 — Docker Build
Creates container image
Stage 7 — Push Image
Uploads image to registry
Stage 8 — Deploy
Updates Kubernetes deployment
Stage 9 — Verify
Ensures deployment success
Step 1: Install Required Tools
On Jenkins Server:
Install:
Java 17
Maven
Docker
Kubectl
Helm
SonarQube Scanner
Install Jenkins Plugins:
Pipeline
Docker Pipeline
Kubernetes
SonarQube Scanner
Nexus Artifact Uploader
Git
JUnit
Step 2: Configure SonarQube in Jenkins
Manage Jenkins → Configure System → SonarQube Servers
Add:
Name: SonarQube
URL: http://your-sonarqube:9000
Token: ********
Step 3: Configure Nexus in Jenkins
Add credentials:
Username
Password
Credentials ID:
nexus-creds
Step 4: Configure DockerHub Credentials
Add credentials:
ID: dockerhub-creds
Step 5: Production-Grade Jenkinsfile
pipeline {
agent any
tools {
maven "M2_HOME"
}
environment {
DOCKER_IMAGE = "yourdockerhub/spring-petclinic"
DOCKER_TAG = "${BUILD_NUMBER}"
SONARQUBE_SERVER = "SonarQube"
OPENAI_API_KEY = credentials('openai-api-key')
}
stages {
stage('Checkout') {
steps {
git branch: 'main',
url: 'https://github.com/spring-projects/spring-petclinic.git'
}
}
stage('Build') {
steps {
sh 'mvn clean compile'
}
}
stage('Unit Test') {
steps {
sh 'mvn test'
}
}
stage('Publish Test Results') {
steps {
junit '*/target/surefire-reports/.xml'
}
}
stage('SonarQube Analysis') {
steps {
withSonarQubeEnv("${SONARQUBE_SERVER}") {
sh '''
mvn sonar:sonar \
-Dsonar.projectKey=petclinic \
-Dsonar.host.url=http://sonarqube:9000
'''
}
}
}
stage('Quality Gate') {
steps {
timeout(time: 5, unit: 'MINUTES') {
waitForQualityGate abortPipeline: true
}
}
}
stage('AI Log Analysis') {
steps {
script {
def logs = sh(
script: "cat target/surefire-reports/*.txt || echo 'No logs'",
returnStdout: true
)
def aiResponse = sh(
script: """
curl https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer ${OPENAI_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"model":"gpt-4o-mini",
"messages":[
{
"role":"user",
"content":"Analyze these Jenkins test logs and predict deployment risk:\n${logs}"
}
]
}'
""",
returnStdout: true
)
echo "AI Analysis Result: ${aiResponse}"
if(aiResponse.contains("HIGH RISK")) {
error "AI detected high deployment risk. Stopping pipeline."
}
}
}
}
stage('Package') {
steps {
sh 'mvn package -DskipTests'
}
}
stage('Upload Artifact to Nexus') {
steps {
nexusArtifactUploader(
nexusVersion: 'nexus3',
protocol: 'http',
nexusUrl: 'nexus:8081',
groupId: 'com.petclinic',
version: "${BUILD_NUMBER}",
repository: 'maven-releases',
credentialsId: 'nexus-creds',
artifacts: [
[
artifactId: 'petclinic',
classifier: '',
file: 'target/*.jar',
type: 'jar'
]
]
)
}
}
stage('Build Docker Image') {
steps {
sh "docker build -t ${DOCKER_IMAGE}:${DOCKER_TAG} ."
}
}
stage('Push Docker Image') {
steps {
withCredentials([usernamePassword(
credentialsId: 'dockerhub-creds',
usernameVariable: 'USER',
passwordVariable: 'PASS'
)]) {
sh "echo $PASS | docker login -u $USER --password-stdin"
sh "docker push ${DOCKER_IMAGE}:${DOCKER_TAG}"
}
}
}
stage('Deploy using Helm') {
steps {
sh """
helm upgrade --install petclinic ./helm-chart \
--set image.repository=${DOCKER_IMAGE} \
--set image.tag=${DOCKER_TAG}
"""
}
}
stage('Verify Deployment') {
steps {
sh "kubectl get pods"
sh "kubectl rollout status deployment/petclinic"
}
}
}
post {
success {
echo "AI-Powered Deployment Successful"
}
failure {
echo "Pipeline Failed or Blocked by AI"
}
}
}
How AI Helps in This Pipeline
AI analyzes:
Test logs
Build failures
Code patterns
Deployment risks
AI decides:
SAFE → Continue deployment
HIGH RISK → Stop deployment
Example AI Output
Analysis Result:
Tests passed successfully.
No critical errors detected.
Deployment risk LOW.
Recommendation: SAFE TO DEPLOY
OR
Analysis Result:
Memory leak detected.
High failure probability.
Recommendation: HIGH RISK
Pipeline stops automatically.
Step 6: Helm Chart Structure
helm-chart/
Chart.yaml
values.yaml
templates/
deployment.yaml
service.yaml
deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: petclinic
spec:
replicas: 2
selector:
matchLabels:
app: petclinic
template:
metadata:
labels:
app: petclinic
spec:
containers:
- name: petclinic
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
ports:
- containerPort: 8080
values.yaml
image:
repository: yourdockerhub/spring-petclinic
tag: latest
Step 7: Nexus Stores Artifacts
Flow:
Jenkins → Nexus → Artifact stored
Benefits:
Version control
Rollback capability
Artifact history
Step 8: SonarQube Quality Gate Protects Production
SonarQube checks:
• Bugs
• Vulnerabilities
• Code smells
• Coverage
If failed:
Pipeline stops.
Step 9: Docker Containerization
Create Dockerfile in project root:
FROM openjdk:17
WORKDIR /app
COPY target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","app.jar"]
Converts app into portable container.
Runs anywhere:
AWS Azure GCP On-prem
Step 10: Kubernetes Deployment
Kubernetes handles:
Scaling
Load balancing
Self healing
Step 11: Final Enterprise
Final Production Pipeline Flow
GitHub
↓
Jenkins
↓
Build
↓
Test
↓
SonarQube
↓
Quality Gate
↓
Nexus
↓
Docker
↓
DockerHub
↓
Helm
↓
Kubernetes
↓
Production
Enterprise Benefits
Prevents bad deployments
Fully automated
Highly scalable
Highly reliable
Rollback supported
Production safe
Top comments (0)