diff --git a/Jenkinsfile b/Jenkinsfile index 8613585..01a5459 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -86,11 +86,21 @@ spec: steps { container('kubectl') { script { + // Print container info for diagnostics + sh 'echo "Running in $(hostname) with kubectl version: $(kubectl version --client)"' + withCredentials([file(credentialsId: "${KUBE_CONFIG_ID}", variable: 'KUBE_CONFIG')]) { - writeFile file: 'kubeconfig', text: KUBE_CONFIG + // Copy kubeconfig to a location with proper permissions + sh 'mkdir -p ~/.kube' + sh 'cp $KUBE_CONFIG ~/.kube/config' + sh 'chmod 600 ~/.kube/config' + + // Apply deployment with proper error handling sh """ - kubectl apply -f deploy/kubernetes/dev.yaml --kubeconfig=kubeconfig - kubectl set image deployment/backend backend=${REGISTRY_URL}/${IMAGE_NAME}:dev-${env.SHORT_SHA} -n nam-backend-dev --kubeconfig=kubeconfig + set -xe + kubectl apply -f deploy/kubernetes/dev.yaml + kubectl set image deployment/backend backend=${REGISTRY_URL}/${IMAGE_NAME}:dev-${env.SHORT_SHA} -n nam-backend-dev + kubectl rollout status deployment/backend -n nam-backend-dev --timeout=60s """ } }