一、说明
1、以下脚本依赖: jenkins已经通过token方式接入到gitlab
二、脚本备份
1、vue项目
1)脚本
cd /var/lib/jenkins/workspace/hg-vue
npm install
npm run build:test
echo "代码路径: /var/lib/jenkins/workspace/hg-vue/dist"
说明1: 编译打包即可
说明2: npm run build:test,需要按需调整;有的是npm run build:prod或者npm run build
~~
2、springboot项目
1)脚本标签:lib,PID,命令,workspace,linux,var,jenkins,hg From: https://blog.51cto.com/u_15891242/5885725
cd /var/lib/jenkins/workspace/hg-java
mvn clean install -Dmaven.test.skip=true
BUILD_ID=dontKillMe
#!/bin/bash
TMP_PID=`netstat -anp|grep 8080|awk '{printf $7}'|cut -d/ -f1`
echo PID: $TMP_PID
if [ ! -n "$TMP_PID" ] ;then
echo "未启动"
else
echo "已启动,关掉PID:"$TMP_PID
kill -9 $TMP_PID
fi
cd /var/lib/jenkins/workspace/hg-java/target
nohup java -Xms512m -Xmx1024m -jar -Dfile.encoding=utf-8 hg-java.jar --spring.profiles.active=test > /var/lib/jenkins/workspace/hg-java/log.out 2>&1 &
echo "查看log: tail -f /var/lib/jenkins/workspace/hg-java/log.out"
说明1: 端口8080,自动关闭
说明2: 需要调整jar包名以及路径
~~