1. web 項目打包shell 腳本
將當前jenkins 中項目發佈到當前服務的 /data/deploy/cc-admin-web/ 目錄下(目錄要提前創建好)
cd ./target
jar_name=$(ls cc*.jar |head -1)
cp -f ./$jar_name /data/deploy/cc-admin-web/$jar_name.${BUILD_VERSION}
rm -f /data/deploy/cc-admin-web/current
ln -sf /data/deploy/cc-admin-web/$jar_name.${BUILD_VERSION} /data/deploy/cc-admin-web/current
cd /data/deploy/cc-admin-web
BUILD_ID=dontKillMe
sh /data/deploy/cc-admin-web/stop.sh
sh /data/deploy/cc-admin-web/start.sh
將項目發佈到其他服務器下腳本
cd ./target
jar_name=$(ls pay-web*.jar |head -1)
scp ./$jar_name [email protected]:/data/deploy/pay-web/$jar_name.${BUILD_VERSION}
#rm -f [email protected]:/data/deploy/pay-web/$jar_name
#ln -sf /data/deploy/pay-web/$jar_name.${BUILD_VERSION} [email protected]:/data/deploy/pay-web/$jar_name.${BUILD_VERSION}.jar
ssh [email protected] > /dev/null 2>&1 << eeooff
cd /data/deploy/pay-web
ps -ef|grep "pay-web-1.0.0.jar" |grep -v "grep" |awk '{print $2}' |xargs kill
rm -rf /data/deploy/pay-web/pay-web-1.0.0.jar
echo $jar_name.${BUILD_VERSION}
ln -sf /data/deploy/pay-web/$jar_name.${BUILD_VERSION} /data/deploy/pay-web/pay-web-1.0.0.jar
exit
eeooff
echo done!
start.sh 腳本
keyword="cc-admin-web"
nohup java -Xms512m -Xmx640m -jar /data/deploy/$keyword/current --spring.config.location=file:/data/deploy/$keyword/ >/data/deploy/$keyword/output.log 2>&1 &
#nohup java -Xms128m -Xmx256m \
#-Djava.rmi.server.hostname=192.168.48.57 \
#-Dcom.sun.management.jmxremote \
#-Dcom.sun.management.jmxremote.port=2200 \
#-Dcom.sun.management.jmxremote.authenticate=false \
#-Dcom.sun.management.jmxremote.ssl=false \
#-jar /data/deploy/$keyword/current --spring.config.location=file:/data/deploy/$keyword/ >/data/deploy/$keyword/output.log 2>&1 &
stop.sh腳本
keyword="cc-admin-web/current"
ps -ef|grep $keyword |grep -v "grep" |awk '{cmd="kill "$2;system(cmd)}'
2. node 項目
node -v
npm -v
npm install
npm run build
echo $path
mkdir dist/nsda-user
mv dist/index.html dist/nsda-user/
mv dist/static dist/nsda-user/
cp -r dist /data/deploy/nsda-user-static/${BUILD_VERSION}
rm -f /data/deploy/nsda-user-static/html
ln -s /data/deploy/nsda-user-static/${BUILD_VERSION} /data/deploy/nsda-user-static/html