SZX-1339生产环境(10.251.113.104)Jenkins 上java部署异常。

This commit is contained in:
xu
2025-12-17 17:45:53 +08:00
parent 8ff8703576
commit 74e3f8f1f3

View File

@@ -0,0 +1,128 @@
#!/bin/sh
## 强制 Jenkins 使用指定 Maven避免命中 /usr/bin/mvn 的旧版本)
MAVEN_HOME=/usr/local/opt/maven3
export MAVEN_HOME
export PATH="$MAVEN_HOME/bin:$PATH"
BOE_SERVER_ALL=boe-server-all-1.1.24.jar
BOE_SERVER_ALL_ORIGIN=boe-server-all-2.0.0.jar
START_ENV=prod
cd ./servers/boe-server-all
#mvn clean package -Dmaven.test.skip=true -P ${START_ENV}
mvn clean package -o -DskipTests -Dmaven.resources.plugin.version=3.1.0 -P ${START_ENV}
rsync -avzlopg --delete --progress ./target/$BOE_SERVER_ALL root@10.251.113.95:/home/system/
rsync -avzlopg --delete --progress ./target/$BOE_SERVER_ALL root@10.251.113.94:/home/system/
rsync -avzlopg --delete --progress ./target/$BOE_SERVER_ALL root@10.251.113.93:/home/system/
rsync -avzlopg --delete --progress ./target/$BOE_SERVER_ALL root@10.251.113.92:/home/system/
rsync -avzlopg --delete --progress ./target/$BOE_SERVER_ALL root@10.251.113.91:/home/system/
rsync -avzlopg --delete --progress ./target/$BOE_SERVER_ALL root@10.251.113.90:/home/system/
ssh -T root@10.251.113.95<<EOF
chown www-data:www-data /home/system/${BOE_SERVER_ALL}
chmod 755 /home/system/${BOE_SERVER_ALL}
EOF
ssh -T root@10.251.113.94<<EOF
chown www-data:www-data /home/system/${BOE_SERVER_ALL}
chmod 755 /home/system/${BOE_SERVER_ALL}
EOF
ssh -T root@10.251.113.93<<EOF
chown www-data:www-data /home/system/${BOE_SERVER_ALL}
chmod 755 /home/system/${BOE_SERVER_ALL}
EOF
ssh -T root@10.251.113.92<<EOF
chown www-data:www-data /home/system/${BOE_SERVER_ALL}
chmod 755 /home/system/${BOE_SERVER_ALL}
EOF
ssh -T root@10.251.113.91<<EOF
chown www-data:www-data /home/system/${BOE_SERVER_ALL}
chmod 755 /home/system/${BOE_SERVER_ALL}
EOF
ssh -T root@10.251.113.90<<EOF
chown www-data:www-data /home/system/${BOE_SERVER_ALL}
chmod 755 /home/system/${BOE_SERVER_ALL}
EOF
system_pid_origin=$(ssh root@10.251.113.95 "ps -ef | grep ${BOE_SERVER_ALL_ORIGIN} | grep -v grep | awk '{print $2}'"| awk '{print $2}')
if [ -n $system_pid_origin ]; then
ssh root@10.251.113.95 "kill -9 ${system_pid_origin}"
fi
system_pid=$(ssh root@10.251.113.95 "ps -ef | grep ${BOE_SERVER_ALL} | grep -v grep | awk '{print $2}'"| awk '{print $2}')
if [ -n $system_pid ]; then
ssh root@10.251.113.95 "kill -9 ${system_pid}"
fi
ssh root@10.251.113.95 "su - www-data -c \"nohup java -Dspring.profiles.active=${START_ENV} -jar -Xms512m -Xmx1024m /home/system/${BOE_SERVER_ALL}> /home/system/nohup.out 2>&1 &\""
system_pid_origin=$(ssh root@10.251.113.94 "ps -ef | grep ${BOE_SERVER_ALL_ORIGIN} | grep -v grep | awk '{print $2}'"| awk '{print $2}')
if [ -n $system_pid_origin ]; then
ssh root@10.251.113.94 "kill -9 ${system_pid_origin}"
fi
system_pid=$(ssh root@10.251.113.94 "ps -ef | grep ${BOE_SERVER_ALL} | grep -v grep | awk '{print $2}'"| awk '{print $2}')
if [ -n $system_pid ]; then
ssh root@10.251.113.94 "kill -9 ${system_pid}"
fi
ssh root@10.251.113.94 "su - www-data -c \"nohup java -Dspring.profiles.active=${START_ENV} -jar -Xms512m -Xmx1024m /home/system/${BOE_SERVER_ALL}> /home/system/nohup.out 2>&1 &\""
system_pid_origin=$(ssh root@10.251.113.93 "ps -ef | grep ${BOE_SERVER_ALL_ORIGIN} | grep -v grep | awk '{print $2}'"| awk '{print $2}')
if [ -n $system_pid_origin ]; then
ssh root@10.251.113.93 "kill -9 ${system_pid_origin}"
fi
system_pid=$(ssh root@10.251.113.93 "ps -ef | grep ${BOE_SERVER_ALL} | grep -v grep | awk '{print $2}'"| awk '{print $2}')
if [ -n $system_pid ]; then
ssh root@10.251.113.93 "kill -9 ${system_pid}"
fi
ssh root@10.251.113.93 "su - www-data -c \"nohup java -Dspring.profiles.active=${START_ENV} -jar -Xms512m -Xmx1024m /home/system/${BOE_SERVER_ALL}> /home/system/nohup.out 2>&1 &\""
system_pid_origin=$(ssh root@10.251.113.92 "ps -ef | grep ${BOE_SERVER_ALL_ORIGIN} | grep -v grep | awk '{print $2}'"| awk '{print $2}')
if [ -n $system_pid_origin ]; then
ssh root@10.251.113.92 "kill -9 ${system_pid_origin}"
fi
system_pid=$(ssh root@10.251.113.92 "ps -ef | grep ${BOE_SERVER_ALL} | grep -v grep | awk '{print $2}'"| awk '{print $2}')
if [ -n $system_pid ]; then
ssh root@10.251.113.92 "kill -9 ${system_pid}"
fi
ssh root@10.251.113.92 "su - www-data -c \"nohup java -Dspring.profiles.active=${START_ENV} -jar -Xms512m -Xmx1024m /home/system/${BOE_SERVER_ALL}> /home/system/nohup.out 2>&1 &\""
system_pid_origin=$(ssh root@10.251.113.91 "ps -ef | grep ${BOE_SERVER_ALL_ORIGIN} | grep -v grep | awk '{print $2}'"| awk '{print $2}')
if [ -n $system_pid_origin ]; then
ssh root@10.251.113.91 "kill -9 ${system_pid_origin}"
fi
system_pid=$(ssh root@10.251.113.91 "ps -ef | grep ${BOE_SERVER_ALL} | grep -v grep | awk '{print $2}'"| awk '{print $2}')
if [ -n $system_pid ]; then
ssh root@10.251.113.91 "kill -9 ${system_pid}"
fi
ssh root@10.251.113.91 "su - www-data -c \"nohup java -Dspring.profiles.active=${START_ENV} -jar -Xms512m -Xmx1024m /home/system/${BOE_SERVER_ALL}> /home/system/nohup.out 2>&1 &\""
system_pid_origin=$(ssh root@10.251.113.90 "ps -ef | grep ${BOE_SERVER_ALL_ORIGIN} | grep -v grep | awk '{print $2}'"| awk '{print $2}')
if [ -n $system_pid_origin ]; then
ssh root@10.251.113.90 "kill -9 ${system_pid_origin}"
fi
system_pid=$(ssh root@10.251.113.90 "ps -ef | grep ${BOE_SERVER_ALL} | grep -v grep | awk '{print $2}'"| awk '{print $2}')
if [ -n $system_pid ]; then
ssh root@10.251.113.90 "kill -9 ${system_pid}"
fi
ssh root@10.251.113.90 "su - www-data -c \"nohup java -Dspring.profiles.active=${START_ENV} -jar -Xms512m -Xmx1024m /home/system/${BOE_SERVER_ALL}> /home/system/nohup.out 2>&1 &\""