|
|
@@ -17,7 +17,7 @@ def call(Map args = [:]) {
|
|
|
PrintMes("开始发布 ${jarName} [profile=${profile}] 到 ${remoteHost}:${remotePort}", 'yellow')
|
|
|
|
|
|
try {
|
|
|
- /* 1. 按端口杀旧进程,并确认端口已释放 (已修复) */
|
|
|
+ /* 1. 按端口杀旧进程,并确认端口已释放 */
|
|
|
sh """
|
|
|
ssh -o StrictHostKeyChecking=no ${remoteHost} '
|
|
|
OLD_PID=\$(lsof -ti:${remotePort} || true)
|
|
|
@@ -33,7 +33,7 @@ def call(Map args = [:]) {
|
|
|
'
|
|
|
"""
|
|
|
|
|
|
- /* 2. 备份旧包 (已修复 Groovy 编译错误) */
|
|
|
+ /* 2. 备份旧包 */
|
|
|
sh """
|
|
|
ssh -o StrictHostKeyChecking=no ${remoteHost} '
|
|
|
test -f ${remoteJar} && mv ${remoteJar} ${remoteJar}-\$(date +%Y%m%d%H%M) || true
|
|
|
@@ -41,18 +41,17 @@ def call(Map args = [:]) {
|
|
|
"""
|
|
|
|
|
|
/* 3. 传包 + MD5 强校验 */
|
|
|
- // 注意:这里的 \S1 是 Groovy GString 的转义,与 Shell 远程命令无关,因此保持不变。
|
|
|
String localMd5 = sh(script: "md5sum ${jarPath} | awk '{print \$1}'", returnStdout: true).trim()
|
|
|
sh "scp -o StrictHostKeyChecking=no ${jarPath} ${remoteHost}:${remoteJar}"
|
|
|
|
|
|
- // 这里的 awk 转义复杂,但 Groovy 编译时没问题,保持不变。
|
|
|
- String remoteMd5 = sh(script: "ssh -o StrictHostKeyChecking=no ${remoteHost} 'md5sum ${remoteJar} | awk \"{print \\\\\$1}\"'", returnStdout: true).trim()
|
|
|
-
|
|
|
+ // ❌ 修复点:修改 awk 脚本的转义方式,使用单引号包裹,并让 Groovy 正确输出 \$1
|
|
|
+ String remoteMd5 = sh(script: "ssh -o StrictHostKeyChecking=no ${remoteHost} 'md5sum ${remoteJar} | awk \\'{print \\\$1}\\' '", returnStdout: true).trim()
|
|
|
+
|
|
|
if (localMd5 != remoteMd5) {
|
|
|
error("MD5 校验失败:本地 ${localMd5} != 远程 ${remoteMd5}")
|
|
|
}
|
|
|
|
|
|
- /* 4. 启动新进程 (已修复 Groovy 编译错误) */
|
|
|
+ /* 4. 启动新进程 */
|
|
|
sh """
|
|
|
ssh -o StrictHostKeyChecking=no ${remoteHost} '
|
|
|
cd ${remotePath} &&
|