JenKins配置参考
JenKins配置参考:
1 2 3
| cd /var/lib/jenkins/workspace/dev-gts-quote && /usr/local/server/apache-maven-3.8.6/bin/mvn clean package scp -r /var/lib/jenkins/workspace/dev-gts-quote/quote-server/target/quote-server-1.0.0.jar labor@10.10.10.4:/home/labor/run/gts-quote/ ssh labor@10.10.10.4 'cp -f ~/run/start.sh /home/labor/run/gts-quote &&cd /home/labor/run/gts-quote/ && /home/labor/run/gts-quote/start.sh restart'
|
/home/labor/run
路径下的start.sh文件内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| #!/bin/sh
NOW_PATH=$(cd `dirname $0`; pwd)
JAR_DIR=`ls -ltr $NOW_PATH/*.jar| tail -1`
JAR_NAME=./${JAR_DIR##*/}
LOG_NAME=${JAR_NAME%%.*}
PID=$LOG_NAME\.pid
case "$1" in
start) mkdir logs nohup /home/labor/jdk-11.0.16.1/bin/java -Xms256m -Xmx1024m -jar $JAR_NAME --spring.profiles.active=dev1 > server.log 2>&1 & echo $! > $NOW_PATH/$PID echo "=== start $JAR_NAME" ;;
stop) echo "=== stop $JAR_NAME" ps -ef|grep $JAR_NAME |grep -v grep |awk '{print $2}'|xargs kill -9 ;;
restart) $0 stop sleep 2 $0 start echo "=== restart $LOG_NAME" ;;
*) echo "Usage:$0 {start|stop|restart}" ;;
esac exit 0
|
start.sh文件是通用文件,但是JenKins配置里的代码需要改jar包名字和路径