testing kubectl

This commit is contained in:
areeqakbr 2025-02-25 14:36:19 +07:00
parent 2886f113f8
commit d005ab82d6
1 changed files with 13 additions and 3 deletions

16
Jenkinsfile vendored
View File

@ -86,11 +86,21 @@ spec:
steps { steps {
container('kubectl') { container('kubectl') {
script { 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')]) { 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 """ sh """
kubectl apply -f deploy/kubernetes/dev.yaml --kubeconfig=kubeconfig set -xe
kubectl set image deployment/backend backend=${REGISTRY_URL}/${IMAGE_NAME}:dev-${env.SHORT_SHA} -n nam-backend-dev --kubeconfig=kubeconfig 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
""" """
} }
} }