兼容查询已有工作负载不存在

This commit is contained in:
dxin
2025-12-02 15:11:19 +08:00
parent 5d2f0732a9
commit b7f0405424
5 changed files with 288 additions and 4 deletions

View File

@@ -114,7 +114,9 @@ pipeline {
steps {
script {
def oldImg = sh (
script: "kubectl get deployment ${Deployment_name} -n ${K8s_namespace} -o=jsonpath='{.spec.template.spec.containers[*].image}'",
script: """
kubectl get deployment ${Deployment_name} -n ${K8s_namespace} -o=jsonpath='{.spec.template.spec.containers[*].image}' 2>/dev/null || echo "无(可能是首次部署)"
""",
returnStdout: true
).trim()
env.OLD_IMAGE_NAME = oldImg