linux自动拉取码云springboot并打包启动半自动脚本方式

linux自动拉取码云springboot并打包启动半自动脚本方式,第1张

linux自动拉取码云springboot并打包启动半自动脚本方式

卸载重装git

git --version

yum remove git

yum -y install git

配置git

git config --global user.name "******"

git config --global user.email "******@126.com"

生成秘钥

ssh-keygen

将公钥文件内容填入码云(头像=》设置=》安全设置=》SSH公钥=》添加)

/root/.ssh/id_rsa.pub


下载maven

​https://dlcdn.apache.org/maven/maven-3/3.8.3/binaries/apache-maven-3.8.3-bin.zip

unzip apache-maven-3.8.3-bin.zip

安装maven

vi /etc/profile

export MAVEN_HOME=/usrapache-maven-3.8.3
export PATH=$PATH:$MAVEN_HOME/bin

:wq!

source /etc/profile

mvn -v

下载git代码

mkdir git

cd git

git clone [email protected]:*******.git

ll -al

git pull origin master

创建脚本

vi deploy.sh

#!/bin/bash
echo 进入项目目录
cd /usrgit/me-server/w4me
echo 拉取最新代码
git pull origin master
echo 关闭老线程
echo $(ps -ef | grep w4me | grep -v grep)
echo $(ps -ef | grep w4me | grep -v grep | awk '{print $2}')
pid=$(ps -ef | grep w4me | grep -v grep | awk '{print $2}')
if [ -n "$pid" ]
then
echo kill -9 $pid
kill -9 $pid
fi
echo 打包启动新线程
mvn clean package -Dmaven.test.skip=true
cp -R /usrgit/me-server/w4me/target/w4me.jar /usrspringboot
nohup java -jar /usrspringboot/w4me.jar --spring.profiles.active=preview &

:wq!

chmod -R 777 ./deploy.sh

部署

./deploy.sh

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5442970.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-11
下一篇 2022-12-11

发表评论

登录后才能评论

评论列表(0条)

保存