diff --git a/apps/demo-nginx/Jenkinsfile.rollback b/apps/demo-nginx/Jenkinsfile.rollback index ddae91e..8d83b57 100644 --- a/apps/demo-nginx/Jenkinsfile.rollback +++ b/apps/demo-nginx/Jenkinsfile.rollback @@ -34,6 +34,7 @@ pipeline { environment { APP_NAME = 'demo-nginx' + CONTAINER_NAME = 'nginx' // Fixed: actual container name NAMESPACE = 'demo-app' DOCKER_REGISTRY = 'docker.io' DOCKER_REPO = 'vladcrypto' @@ -77,6 +78,12 @@ pipeline { -o jsonpath='{.spec.template.spec.containers[0].image}' echo "" + echo "" + echo "=== Container Name ===" + kubectl get deployment ${APP_NAME} -n ${NAMESPACE} \ + -o jsonpath='{.spec.template.spec.containers[0].name}' + echo "" + echo "" echo "=== Current Pods ===" kubectl get pods -n ${NAMESPACE} -l app=${APP_NAME} @@ -130,11 +137,11 @@ pipeline { echo "🚀 Executing rollback..." if (params.ROLLBACK_METHOD == 'IMAGE_TAG') { - // Method 1: Update image directly + // Method 1: Update image directly using correct container name sh """ echo "Setting image to: ${env.TARGET_IMAGE}" kubectl set image deployment/${APP_NAME} \ - ${APP_NAME}=${env.TARGET_IMAGE} \ + ${CONTAINER_NAME}=${env.TARGET_IMAGE} \ -n ${NAMESPACE} \ --record """ @@ -271,6 +278,10 @@ pipeline { echo "" echo "=== New Pods ===" kubectl get pods -n ${NAMESPACE} -l app=${APP_NAME} + + echo "" + echo "=== Updated Rollout History ===" + kubectl rollout history deployment/${APP_NAME} -n ${NAMESPACE} """ } } @@ -313,6 +324,7 @@ pipeline { ✅ ROLLBACK SUCCESSFUL! Application: ${APP_NAME} + Container: ${CONTAINER_NAME} Method: ${params.ROLLBACK_METHOD} Target: ${params.TARGET_VERSION} Namespace: ${NAMESPACE} @@ -329,8 +341,11 @@ pipeline { Please check the logs and try again. - Manual rollback command: + Manual rollback commands: kubectl rollout undo deployment/${APP_NAME} -n ${NAMESPACE} + + Or set image directly: + kubectl set image deployment/${APP_NAME} ${CONTAINER_NAME}= -n ${NAMESPACE} """ } }