Update Jenkinsfile.backup
Some checks failed
ecommerce admin pannel/pipeline/head There was a failure building this commit
Some checks failed
ecommerce admin pannel/pipeline/head There was a failure building this commit
This commit is contained in:
98
Jenkinsfile
vendored
98
Jenkinsfile
vendored
@@ -1,98 +0,0 @@
|
|||||||
pipeline {
|
|
||||||
agent any
|
|
||||||
|
|
||||||
parameters {
|
|
||||||
string(
|
|
||||||
name: 'NODE_IP',
|
|
||||||
defaultValue: '192.168.108.200',
|
|
||||||
description: 'On-premise Kubernetes node IP'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
environment {
|
|
||||||
HARBOR = '192.168.108.200:80'
|
|
||||||
IMAGE = '192.168.108.200:80/vaishnavi-ecommerce/admin'
|
|
||||||
OLD_IMAGE = '192.168.49.2:30004/vaishnavi-ecommerce/admin:latest'
|
|
||||||
TAG = "${env.BUILD_NUMBER}"
|
|
||||||
NAMESPACE = 'ecommerce'
|
|
||||||
APP_NAME = 'VC E-Commerce Admin Panel'
|
|
||||||
}
|
|
||||||
|
|
||||||
stages {
|
|
||||||
stage('Build Image') {
|
|
||||||
steps {
|
|
||||||
sh """
|
|
||||||
docker build \
|
|
||||||
--build-arg VITE_API_URL=http://${params.NODE_IP}:30080/api \
|
|
||||||
--build-arg "VITE_APP_NAME=${APP_NAME}" \
|
|
||||||
-t ${IMAGE}:${TAG} \
|
|
||||||
-t ${IMAGE}:latest \
|
|
||||||
.
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Push to Harbor') {
|
|
||||||
steps {
|
|
||||||
withCredentials([usernamePassword(
|
|
||||||
credentialsId: 'harbor-credentials',
|
|
||||||
usernameVariable: 'HARBOR_USER',
|
|
||||||
passwordVariable: 'HARBOR_PASS'
|
|
||||||
)]) {
|
|
||||||
sh """
|
|
||||||
echo "\$HARBOR_PASS" | docker login ${HARBOR} -u "\$HARBOR_USER" --password-stdin
|
|
||||||
docker push ${IMAGE}:${TAG}
|
|
||||||
docker push ${IMAGE}:latest
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Deploy') {
|
|
||||||
steps {
|
|
||||||
withCredentials([file(credentialsId: 'kubeconfig', variable: 'KUBECONFIG')]) {
|
|
||||||
sh """
|
|
||||||
sed "s|${OLD_IMAGE}|${IMAGE}:${TAG}|g" \
|
|
||||||
k8s/deployment.yaml | kubectl apply -f -
|
|
||||||
kubectl apply -f k8s/service.yaml
|
|
||||||
kubectl apply -f k8s/ingress.yaml
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Verify Rollout') {
|
|
||||||
steps {
|
|
||||||
withCredentials([file(credentialsId: 'kubeconfig', variable: 'KUBECONFIG')]) {
|
|
||||||
sh "kubectl rollout status deployment/admin -n ${NAMESPACE} --timeout=180s"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('Smoke Test') {
|
|
||||||
steps {
|
|
||||||
sh """
|
|
||||||
STATUS=\$(curl -o /dev/null -sw "%{http_code}" http://${params.NODE_IP}:30082)
|
|
||||||
echo "HTTP status: \$STATUS"
|
|
||||||
[ "\$STATUS" = "200" ]
|
|
||||||
"""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
post {
|
|
||||||
always {
|
|
||||||
sh "docker rmi ${IMAGE}:${TAG} || true"
|
|
||||||
sh "docker rmi ${IMAGE}:latest || true"
|
|
||||||
}
|
|
||||||
success {
|
|
||||||
echo "Deploy successful. Admin panel accessible at http://${params.NODE_IP}:30082"
|
|
||||||
}
|
|
||||||
failure {
|
|
||||||
withCredentials([file(credentialsId: 'kubeconfig', variable: 'KUBECONFIG')]) {
|
|
||||||
sh "kubectl get pods -n ${NAMESPACE} || true"
|
|
||||||
sh "kubectl describe deployment/admin -n ${NAMESPACE} || true"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
77
Jenkinsfile.backup
Normal file
77
Jenkinsfile.backup
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
environment {
|
||||||
|
HARBOR = 'harbor.myriadcara.com'
|
||||||
|
IMAGE = 'harbor.myriadcara.com/vaishnavi-ecommerce/admin'
|
||||||
|
VERSION_FILE = '/home/jenkins/vaishnavi-admin-version.txt'
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
|
||||||
|
stage('Generate Tag') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
def version
|
||||||
|
if (fileExists(VERSION_FILE)) {
|
||||||
|
version = readFile(VERSION_FILE).trim()
|
||||||
|
} else {
|
||||||
|
version = '1.0.0'
|
||||||
|
}
|
||||||
|
def parts = version.tokenize('.')
|
||||||
|
def major = parts[0].toInteger()
|
||||||
|
def minor = parts[1].toInteger()
|
||||||
|
def patch = parts[2].toInteger() + 1
|
||||||
|
def newVersion = "${major}.${minor}.${patch}"
|
||||||
|
writeFile file: VERSION_FILE, text: newVersion
|
||||||
|
env.TAG = newVersion
|
||||||
|
echo "🏷️ New image tag: v${env.TAG}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Build Image') {
|
||||||
|
steps {
|
||||||
|
sh """
|
||||||
|
docker build \
|
||||||
|
--provenance=false \
|
||||||
|
--sbom=false \
|
||||||
|
-t ${IMAGE}:${env.TAG} \
|
||||||
|
-t ${IMAGE}:latest \
|
||||||
|
--label build-number=${env.BUILD_NUMBER} \
|
||||||
|
--label version=${env.TAG} \
|
||||||
|
.
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Push to Harbor') {
|
||||||
|
steps {
|
||||||
|
withCredentials([usernamePassword(
|
||||||
|
credentialsId: 'harbor-creds',
|
||||||
|
usernameVariable: 'HARBOR_USER',
|
||||||
|
passwordVariable: 'HARBOR_PASS'
|
||||||
|
)]) {
|
||||||
|
sh """
|
||||||
|
echo "\$HARBOR_PASS" | docker login https://${HARBOR} -u "\$HARBOR_USER" --password-stdin
|
||||||
|
docker push ${IMAGE}:${env.TAG}
|
||||||
|
docker push ${IMAGE}:latest
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
sh "docker rmi ${IMAGE}:${env.TAG} || true"
|
||||||
|
sh "docker rmi ${IMAGE}:latest || true"
|
||||||
|
}
|
||||||
|
success {
|
||||||
|
echo "✅ Successfully pushed: ${IMAGE}:${env.TAG}"
|
||||||
|
}
|
||||||
|
failure {
|
||||||
|
echo "❌ Pipeline failed at tag: ${env.TAG}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user