fix(cicd): 部署 SSH 用 IP 直连 + sudo docker
实测 Jenkins 容器内无 cd-target ssh 别名(/root/.ssh/config 不存在), 且 cd-target 的 ubuntu 用户 docker 需 sudo(NOPASSWD 已配)。 - DEPLOY_HOST: cd-target → ubuntu@110.42.240.10 - 远程命令: docker → sudo docker
This commit is contained in:
parent
aab0db2b68
commit
8345c478c8
9
Jenkinsfile
vendored
9
Jenkinsfile
vendored
@ -9,7 +9,8 @@ pipeline {
|
||||
HARBOR = "43.134.235.58:58080"
|
||||
IMAGE = "${HARBOR}/buildflow/buildflow-api"
|
||||
TAG = "${env.BUILD_NUMBER}"
|
||||
DEPLOY_HOST = "cd-target"
|
||||
// Jenkins 容器内无 ssh 别名,直接用 IP;ubuntu 用户 sudo 免密(NOPASSWD)
|
||||
DEPLOY_HOST = "ubuntu@110.42.240.10"
|
||||
APP_PORT = "5667"
|
||||
}
|
||||
options {
|
||||
@ -47,9 +48,9 @@ pipeline {
|
||||
try {
|
||||
sh """
|
||||
ssh -o StrictHostKeyChecking=accept-new ${DEPLOY_HOST} '
|
||||
docker pull ${IMAGE}:latest
|
||||
docker rm -f buildflow-api 2>/dev/null || true
|
||||
docker run -d --name buildflow-api --restart unless-stopped -p ${APP_PORT}:${APP_PORT} ${IMAGE}:latest
|
||||
sudo docker pull ${IMAGE}:latest
|
||||
sudo docker rm -f buildflow-api 2>/dev/null || true
|
||||
sudo docker run -d --name buildflow-api --restart unless-stopped -p ${APP_PORT}:${APP_PORT} ${IMAGE}:latest
|
||||
'
|
||||
"""
|
||||
echo "部署完成"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user