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