AI-Powered Enterprise CI/CD Pipeline: Jenkins + OpenAI + SonarQube + Nexus + Docker + Kubernetes + Helm

Published: (February 16, 2026 at 01:08 AM EST)
4 min read
Source: Dev.to

Source: Dev.to

Key DevOps Concepts Implemented

  • CI (Continuous Integration) – Automated build
  • CD (Continuous Delivery) – Automated deployment
  • Quality Gate – Code quality validation
  • Containerization – Docker images
  • Orchestration – Kubernetes

Pipeline Execution Flow

StageDescription
Stage 1 – CheckoutPulls code from GitHub
Stage 2 – BuildCompiles application
Stage 3 – TestRuns unit tests
Stage 4 – Quality GateValidates code quality
Stage 5 – PackageCreates JAR file
Stage 6 – Docker BuildCreates container image
Stage 7 – Push ImageUploads image to registry
Stage 8 – DeployUpdates Kubernetes deployment
Stage 9 – VerifyEnsures deployment success

Setup Steps

Step 1: Install Required Tools (Jenkins Server)

  • Java 17
  • Jenkins plugins: Pipeline

Step 2: Configure SonarQube in Jenkins

  1. Manage Jenkins → Configure System → SonarQube Servers
  2. Add server:
    • Name: SonarQube
    • URL: http://your-sonarqube:9000

Step 3: Configure Nexus in Jenkins

  • Add Nexus credentials (e.g., nexus-creds) in Jenkins → Credentials.

Step 4: Configure DockerHub Credentials

  • Add credentials with ID dockerhub-creds (username/password).

Production-Grade Jenkinsfile

pipeline {
    agent any
    environment {
        DOCKER_IMAGE = "yourdockerhub/spring-petclinic"
        NEXUS_URL    = "http://your-nexus:8081"
        SONARQUBE    = "SonarQube"
    }

    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('SonarQube Analysis') {
            steps {
                withSonarQubeEnv("${SONARQUBE}") {
                    sh 'mvn sonar:sonar'
                }
            }
        }

        stage('Quality Gate') {
            steps {
                timeout(time: 5, unit: 'MINUTES') {
                    waitForQualityGate abortPipeline: true
                }
            }
        }

        stage('Package') {
            steps {
                sh 'mvn package -DskipTests'
            }
        }

        stage('Upload to Nexus') {
            steps {
                nexusArtifactUploader(
                    nexusVersion: 'nexus3',
                    protocol: 'http',
                    nexusUrl: 'your-nexus:8081',
                    groupId: 'com.petclinic',
                    version: "${BUILD_NUMBER}",
                    repository: 'maven-releases',
                    credentialsId: 'nexus-creds',
                    artifacts: [
                        [
                            artifactId: 'petclinic',
                            classifier: '',
                            file: 'target/*.jar',
                            type: 'jar'
                        ]
                    ]
                )
            }
        }

        stage('Docker Build') {
            steps {
                sh "docker build -t ${DOCKER_IMAGE}:${DOCKER_TAG} ."
            }
        }

        stage('Docker Push') {
            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('Helm Deploy to Kubernetes') {
            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 get svc"
            }
        }
    }

    post {
        success {
            echo "Production Deployment Successful"
        }
        failure {
            echo "Pipeline Failed"
        }
    }
}

Helm Chart Structure

helm-chart/
├─ Chart.yaml
├─ values.yaml
└─ templates/
   └─ deployment.yaml

deployment.yaml (excerpt)

apiVersion: apps/v1
kind: Deployment
metadata:
  name: petclinic
spec:
  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 (excerpt)

image:
  repository: yourdockerhub/spring-petclinic
  tag: latest

Artifact Storage in Nexus

  • Flow: Jenkins → Nexus → Artifact stored
  • Benefits: Version control of built JARs.

SonarQube Quality Gate

  • SonarQube evaluates code quality metrics and blocks the pipeline if the quality gate fails, protecting production from low‑quality code.

Docker Containerization

Create a Dockerfile in the project root:

FROM openjdk:17
WORKDIR /app
COPY target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","app.jar"]

This converts the Spring Petclinic application into a portable container image.

Kubernetes Deployment

Kubernetes orchestrates the containerized application, handling scaling, service discovery, and self‑healing.

Final Enterprise Pipeline Flow

GitHub → Jenkins → SonarQube → Nexus → Docker Hub → Helm → Kubernetes

Enterprise Benefits

  • Prevents bad deployments
  • Fully automated end‑to‑end pipeline
  • Highly scalable and reliable
  • Supports rollbacks
  • Production‑safe delivery

0 views
Back to Blog

Related posts

Read more »

Preface

Motivation I wanted to record my studies to have consistency. Since I don't directly learn building projects from my CS program, I want to be an expert in my a...