diff --git a/Jenkinsfile b/Jenkinsfile index 53539ab..33904fa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -183,17 +183,22 @@ pipeline { services.each { service -> echo "Deploying ${service}..." - // 使用明确的命令格式 + // 通过 SSH 在宿主机上执行部署命令 + // Jenkins 容器网络: 1panel-network, Gateway: 172.19.0.1 sh """ - cd /opt/aiot-platform-cloud - /usr/bin/docker compose -f docker-compose.core.yml pull ${service} - /usr/bin/docker compose -f docker-compose.core.yml up -d ${service} + ssh -o StrictHostKeyChecking=no root@172.19.0.1 ' + cd /opt/aiot-platform-cloud + docker compose -f docker-compose.core.yml pull ${service} + docker compose -f docker-compose.core.yml up -d ${service} + ' """ // 等待服务健康检查 echo "Waiting for ${service} to be healthy..." sh """ - timeout 120 sh -c 'until docker inspect --format="{{.State.Health.Status}}" aiot-${service} 2>/dev/null | grep -q healthy; do sleep 5; done' || true + ssh -o StrictHostKeyChecking=no root@172.19.0.1 ' + timeout 120 sh -c "until docker inspect --format=\\"{{.State.Health.Status}}\\" aiot-${service} 2>/dev/null | grep -q healthy; do sleep 5; done" || true + ' """ }