From cb75e7096a46f33a0b932d4339b9f01b625fd5c5 Mon Sep 17 00:00:00 2001 From: xiangning Date: Fri, 17 Jul 2026 11:36:07 +0800 Subject: [PATCH] =?UTF-8?q?fix(cicd):=20=E9=83=A8=E7=BD=B2=20SSH=20?= =?UTF-8?q?=E7=94=A8=20IP=20=E7=9B=B4=E8=BF=9E=20+=20sudo=20docker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 实测 Jenkins 容器内无 cd-target ssh 别名,cd-target docker 需 sudo。 - DEPLOY_HOST: cd-target → ubuntu@110.42.240.10 - 远程命令: docker → sudo docker --- Jenkinsfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8cab030..d3ce10f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,7 +8,8 @@ pipeline { HARBOR = "43.134.235.58:58080" IMAGE = "${HARBOR}/buildflow/buildflow-portal" TAG = "${env.BUILD_NUMBER}" - DEPLOY_HOST = "cd-target" + // Jenkins 容器内无 ssh 别名,直接用 IP;ubuntu 用户 sudo 免密(NOPASSWD) + DEPLOY_HOST = "ubuntu@110.42.240.10" APP_PORT = "5173" } options { @@ -46,9 +47,9 @@ pipeline { try { sh """ ssh -o StrictHostKeyChecking=accept-new ${DEPLOY_HOST} ' - docker pull ${IMAGE}:latest - docker rm -f buildflow-portal 2>/dev/null || true - docker run -d --name buildflow-portal --restart unless-stopped -p ${APP_PORT}:${APP_PORT} ${IMAGE}:latest + sudo docker pull ${IMAGE}:latest + sudo docker rm -f buildflow-portal 2>/dev/null || true + sudo docker run -d --name buildflow-portal --restart unless-stopped -p ${APP_PORT}:${APP_PORT} ${IMAGE}:latest ' """ echo "部署完成"