diff --git a/SCM/build_image_flymoon_admin.groovy b/SCM/build_image_flymoon_admin.groovy index 6accc92..f2eb6d0 100644 --- a/SCM/build_image_flymoon_admin.groovy +++ b/SCM/build_image_flymoon_admin.groovy @@ -181,10 +181,12 @@ pipeline { def imageId = parts[0] def tag = parts[1] - // 跳过 latest - if (tag != "latest") { + if (tag == "") { + echo "删除旧镜像(无标签): ${imageId}" + sh(returnStatus: true, script: "docker rmi -f ${imageId}") + } else if (tag != "latest") { echo "删除旧镜像: ${imagePrefix}:${tag}" - sh "docker rmi -f ${imagePrefix}:${tag} || true" + sh(returnStatus: true, script: "docker rmi -f ${imagePrefix}:${tag}") } } } else { diff --git a/SCM/build_image_flymoon_agent.groovy b/SCM/build_image_flymoon_agent.groovy index 7abcf6a..61bddcb 100644 --- a/SCM/build_image_flymoon_agent.groovy +++ b/SCM/build_image_flymoon_agent.groovy @@ -181,10 +181,12 @@ pipeline { def imageId = parts[0] def tag = parts[1] - // 跳过 latest - if (tag != "latest") { + if (tag == "") { + echo "删除旧镜像(无标签): ${imageId}" + sh(returnStatus: true, script: "docker rmi -f ${imageId}") + } else if (tag != "latest") { echo "删除旧镜像: ${imagePrefix}:${tag}" - sh "docker rmi -f ${imagePrefix}:${tag} || true" + sh(returnStatus: true, script: "docker rmi -f ${imagePrefix}:${tag}") } } } else { diff --git a/SCM/build_image_flymoon_payment.groovy b/SCM/build_image_flymoon_payment.groovy index 67338ca..4d276cd 100644 --- a/SCM/build_image_flymoon_payment.groovy +++ b/SCM/build_image_flymoon_payment.groovy @@ -181,10 +181,12 @@ pipeline { def imageId = parts[0] def tag = parts[1] - // 跳过 latest - if (tag != "latest") { + if (tag == "") { + echo "删除旧镜像(无标签): ${imageId}" + sh(returnStatus: true, script: "docker rmi -f ${imageId}") + } else if (tag != "latest") { echo "删除旧镜像: ${imagePrefix}:${tag}" - sh "docker rmi -f ${imagePrefix}:${tag} || true" + sh(returnStatus: true, script: "docker rmi -f ${imagePrefix}:${tag}") } } } else { diff --git a/SCM/build_image_go_lessie_sourcing_api.groovy b/SCM/build_image_go_lessie_sourcing_api.groovy index 8c0aeb1..b8f9bc8 100644 --- a/SCM/build_image_go_lessie_sourcing_api.groovy +++ b/SCM/build_image_go_lessie_sourcing_api.groovy @@ -183,10 +183,12 @@ pipeline { def imageId = parts[0] def tag = parts[1] - // 跳过 latest - if (tag != "latest") { + if (tag == "") { + echo "删除旧镜像(无标签): ${imageId}" + sh(returnStatus: true, script: "docker rmi -f ${imageId}") + } else if (tag != "latest") { echo "删除旧镜像: ${imagePrefix}:${tag}" - sh "docker rmi -f ${imagePrefix}:${tag} || true" + sh(returnStatus: true, script: "docker rmi -f ${imagePrefix}:${tag}") } } } else { diff --git a/SCM/build_image_lessie_ai_web.groovy b/SCM/build_image_lessie_ai_web.groovy index d3c0b48..d1da7e7 100644 --- a/SCM/build_image_lessie_ai_web.groovy +++ b/SCM/build_image_lessie_ai_web.groovy @@ -194,10 +194,12 @@ pipeline { def imageId = parts[0] def tag = parts[1] - // 跳过 latest - if (tag != "latest") { + if (tag == "") { + echo "删除旧镜像(无标签): ${imageId}" + sh(returnStatus: true, script: "docker rmi -f ${imageId}") + } else if (tag != "latest") { echo "删除旧镜像: ${imagePrefix}:${tag}" - sh "docker rmi -f ${imagePrefix}:${tag} || true" + sh(returnStatus: true, script: "docker rmi -f ${imagePrefix}:${tag}") } } } else { diff --git a/SCM/build_image_lessie_sourcing_agents.groovy b/SCM/build_image_lessie_sourcing_agents.groovy index f98b8fd..eb39a0c 100644 --- a/SCM/build_image_lessie_sourcing_agents.groovy +++ b/SCM/build_image_lessie_sourcing_agents.groovy @@ -164,10 +164,12 @@ pipeline { def imageId = parts[0] def tag = parts[1] - // 跳过 latest - if (tag != "latest") { + if (tag == "") { + echo "删除旧镜像(无标签): ${imageId}" + sh(returnStatus: true, script: "docker rmi -f ${imageId}") + } else if (tag != "latest") { echo "删除旧镜像: ${imagePrefix}:${tag}" - sh "docker rmi -f ${imagePrefix}:${tag} || true" + sh(returnStatus: true, script: "docker rmi -f ${imagePrefix}:${tag}") } } } else { diff --git a/k8s_yaml/test/test-flymoon-agent.yaml b/k8s_yaml/test/test-flymoon-agent.yaml index 77d3134..ed7ca8a 100644 --- a/k8s_yaml/test/test-flymoon-agent.yaml +++ b/k8s_yaml/test/test-flymoon-agent.yaml @@ -38,8 +38,8 @@ spec: type: DirectoryOrCreate containers: - name: test-flymoon-agent # 容器名称 - image: uswccr.ccs.tencentyun.com/lessietest/flymoon-agent:v0.0.2 # 容器镜像 - imagePullPolicy: IfNotPresent # 镜像拉取策略 ,有则不拉 + image: uswccr.ccs.tencentyun.com/lessietest/flymoon-agent:v0.0.5 # 容器镜像 + imagePullPolicy: Always # 镜像拉取策略 ,有则不拉 env: - name: POD_NAME valueFrom: diff --git a/k8s_yaml/test/test-flymoon-payment.yaml b/k8s_yaml/test/test-flymoon-payment.yaml index 319970d..7338a64 100644 --- a/k8s_yaml/test/test-flymoon-payment.yaml +++ b/k8s_yaml/test/test-flymoon-payment.yaml @@ -38,8 +38,8 @@ spec: type: DirectoryOrCreate containers: - name: test-flymoon-payment # 容器名称 - image: uswccr.ccs.tencentyun.com/lessietest/flymoon-payment:v0.0.3 # 容器镜像 - imagePullPolicy: IfNotPresent # 镜像拉取策略 ,有则不拉 + image: uswccr.ccs.tencentyun.com/lessietest/flymoon-payment:v0.0.7 # 容器镜像 + imagePullPolicy: Always # 镜像拉取策略,总是拉取 env: - name: POD_NAME valueFrom: @@ -88,4 +88,3 @@ spec: port: 8090 # ClusterIP 内部端口 targetPort: 8090 # 容器端口 nodePort: 30809 # 节点对外端口(30000-32767) -