jenkinsfile
Some checks failed
eCommerce-backend/pipeline/head There was a failure building this commit

This commit is contained in:
2026-02-22 14:59:13 +00:00
parent 019d37dd25
commit b11ec5bfa7

51
Jenkinsfile vendored
View File

@@ -11,8 +11,8 @@ pipeline {
IMAGE = '192.168.108.200:80/vaishnavi-ecommerce/ecommerce-backend' IMAGE = '192.168.108.200:80/vaishnavi-ecommerce/ecommerce-backend'
SONAR_HOST_URL = 'http://sonarqube.example.com:9000' // ← update this // SONAR_HOST_URL = 'http://sonarqube.example.com:9000' // ← update this
SONAR_PROJECT = 'ecommerce-backend' // SONAR_PROJECT = 'ecommerce-backend'
} }
options { options {
@@ -37,27 +37,29 @@ pipeline {
} }
} }
stage('SonarQube Analysis') { // ─── SonarQube stages disabled until credentials are resolved ───
steps { // stage('SonarQube Analysis') {
withSonarQubeEnv('SonarQube') { // steps {
sh """ // withSonarQubeEnv('SonarQube') {
npx sonar-scanner \ // sh """
-Dsonar.projectKey=${SONAR_PROJECT} \ // npx sonar-scanner \
-Dsonar.projectName='eCommerce Backend' \ // -Dsonar.projectKey=${SONAR_PROJECT} \
-Dsonar.sources=src \ // -Dsonar.projectName='eCommerce Backend' \
-Dsonar.host.url=${SONAR_HOST_URL} // -Dsonar.sources=src \
""" // -Dsonar.host.url=${SONAR_HOST_URL}
} // """
} // }
} // }
// }
stage('Quality Gate') { // stage('Quality Gate') {
steps { // steps {
timeout(time: 5, unit: 'MINUTES') { // timeout(time: 5, unit: 'MINUTES') {
waitForQualityGate abortPipeline: false // waitForQualityGate abortPipeline: false
} // }
} // }
} // }
// ────────────────────────────────────────────────────────────────
stage('Build Image') { stage('Build Image') {
steps { steps {
@@ -89,8 +91,6 @@ pipeline {
stage('Patch Image Tag') { stage('Patch Image Tag') {
steps { steps {
// kustomize edit set image patches the 'name: ecommerce-backend'
// entry in overlays/on-premise/kustomization.yaml
dir("${K8S_OVERLAY}") { dir("${K8S_OVERLAY}") {
sh """ sh """
kustomize edit set image \ kustomize edit set image \
@@ -105,11 +105,9 @@ pipeline {
withKubeConfig([credentialsId: "${K8S_CRED_ID}"]) { withKubeConfig([credentialsId: "${K8S_CRED_ID}"]) {
sh "kubectl apply -k ${K8S_OVERLAY}" sh "kubectl apply -k ${K8S_OVERLAY}"
// Databases first — they must be Ready before the app starts
sh "kubectl rollout status statefulset/postgres -n ${K8S_NAMESPACE} --timeout=300s" sh "kubectl rollout status statefulset/postgres -n ${K8S_NAMESPACE} --timeout=300s"
sh "kubectl rollout status statefulset/mongodb -n ${K8S_NAMESPACE} --timeout=300s" sh "kubectl rollout status statefulset/mongodb -n ${K8S_NAMESPACE} --timeout=300s"
// Then the main app (initContainers wait for DBs + run migrations)
sh "kubectl rollout status deployment/ecommerce-app -n ${K8S_NAMESPACE} --timeout=300s" sh "kubectl rollout status deployment/ecommerce-app -n ${K8S_NAMESPACE} --timeout=300s"
echo "✅ Backend deployed successfully." echo "✅ Backend deployed successfully."
@@ -120,7 +118,6 @@ pipeline {
stage('Smoke Test') { stage('Smoke Test') {
steps { steps {
withKubeConfig([credentialsId: "${K8S_CRED_ID}"]) { withKubeConfig([credentialsId: "${K8S_CRED_ID}"]) {
// Health endpoint is /health on port 80 (ClusterIP service maps 80→3000)
sh """ sh """
kubectl run smoke-${BUILD_NUMBER} \ kubectl run smoke-${BUILD_NUMBER} \
--image=curlimages/curl:latest \ --image=curlimages/curl:latest \