java-mall-app/Jenkinsfile
panjunjie 2012e82d4b 去掉从节点脚本
去掉从节点脚本

Signed-off-by: panjunjie <46790855@qq.com>
2025-12-12 20:47:59 +08:00

44 lines
1.6 KiB
Groovy
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

pipeline {
agent any
environment {
DEPLOY_DIR = '/data/nginx/www/fafamall/h5' // 主节点部署目录(保留原配置)
DIST_PATH = 'dist' // 编译产物目录(保留原配置)
SLAVE_IP = '172.16.0.10' // 从节点 IP与之前一致
SLAVE_DEPLOY_DIR = '/data/nginx/www/fafamall/h5' // 从节点目标目录(与主节点一致)
SSH_PORT = '2203' // 从节点 SSH 端口(固定配置)
SSH_KEY = '/root/.ssh/id_rsa' // 主节点免密私钥路径(固定配置)
}
stages {
stage('拉取代码并验证') {
steps {
checkout scm
sh """
[ -d "${DIST_PATH}" ] || { echo "错误:未找到 ${DIST_PATH} 文件夹"; exit 1; }
echo "${DIST_PATH} 验证通过"
"""
}
}
stage('主节点部署') {
steps {
sh """
mkdir -p ${DEPLOY_DIR}
rm -rf ${DEPLOY_DIR}/*
cp -r ${DIST_PATH}/* ${DEPLOY_DIR}/
echo "主节点部署完成:${DIST_PATH} → ${DEPLOY_DIR}"
echo "重启 Nginx 服务..."
systemctl restart nginx
echo "已重启服务"
"""
}
}
}
post {
success { echo "🎉 h5 项目 - 主节点部署+从节点同步+Nginx重启全部完成" }
failure { echo "❌ h5 项目 - 部署/同步流程失败,请排查问题后重试" }
}
}