Selaa lähdekoodia

Jenkins 从UAT生成生产环境镜像脚本.

dujian 1 päivä sitten
vanhempi
commit
93a6a1b5aa
1 muutettua tiedostoa jossa 3 lisäystä ja 2 poistoa
  1. 3 2
      docs/jenkins/Jenkinsfile-prod-promote-from-uat.groovy

+ 3 - 2
docs/jenkins/Jenkinsfile-prod-promote-from-uat.groovy

@@ -1471,7 +1471,8 @@ printf '%s' "\$OUT"
                                     for j in 1 2 3 4 5 6; do
                                         for try_dest in "\$JCP" "\$JCP_ALT"; do
                                             [ -n "\$try_dest" ] || continue
-                                            if docker exec "\$CNAME" sh -c 'test -f "\$1" && test -s "\$1" && ! test -d "\$1"' sh "\$try_dest" 2>/dev/null; then
+                                            # 勿用 sh -c 内嵌 &&:经远程 docker 函数 ssh 传参时 && 会在远端 shell 被拆开,导致误判 jar 不存在
+                                            if docker exec "\$CNAME" test -f "\$try_dest" -a -s "\$try_dest" 2>/dev/null; then
                                                 JCP_RESOLVED="\$try_dest"
                                                 break 2
                                             fi
@@ -1510,7 +1511,7 @@ printf '%s' "\$OUT"
                                         echo ">>> 提示: 未在 Mounts 中看到 Destination 精确为 \$JCP_RESOLVED(常为目录 bind /app,可忽略本项)"
                                     fi
                                     if [ "\$PROMOTE_PROD_DIR" = "store" ] && [ "\$CERT_VOL" -eq 1 ]; then
-                                        if ! docker exec "\$CNAME" sh -c 'test -f /usr/local/alien/aliPayCert/apiclient_key.pem' 2>/dev/null; then
+                                        if ! docker exec "\$CNAME" test -f /usr/local/alien/aliPayCert/apiclient_key.pem 2>/dev/null; then
                                             echo "ERROR: store 容器内仍无 /usr/local/alien/aliPayCert/apiclient_key.pem。请 docker inspect \$CNAME 核对 Mounts 与生产 compose 中证书卷。"
                                             exit 1
                                         fi