jenkins启动springboot项目shell脚本

#!/bin/bash -ile
project=aroundnow-single-0.0.1-SNAPSHOT.jar
pathName=aroundnow-single
echo "拷贝文件"
rm -rf /opt/springboot/$project
cp  /var/lib/jenkins/workspace/$pathName/target/$project /opt/springboot/
echo "切换路径"
cd /opt/springboot/
 
pid=`ps -ef | grep $dir$project | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ]
then
   kill -9 $pid
   echo "杀死存在进程"
fi
BUILD_ID=dontKillMe 
echo "执行"
nohup java -jar $project --spring.profiles.active=dev &
echo "启动成功!"

如果出现奇奇怪怪的符号导致命令执行失败,那是因为在windows上编辑过放到linux上要转码,安装

yum install dos2unix

执行

dos2unix ***.sh

你可能感兴趣的:(springboot,linux,Jenkins,shell,spring,boot,jenkins,devops)