Maven project one-click deployment

No login

# 生成秘钥
tianshl:.ssh tianshl$ ssh-keygen -t rsa -P ''

# 将公钥添加至服务器的authorized_keys中
tianshl:.ssh tianshl$ ssh-copy-id -i ./id_rsa.pub [email protected]

Create script

# 项目根目录下创建脚本,名为:update.sh, 内容如下

#!/usr/bin/env bash

# 更新
git pull

# 打包
mvn clean package -Dmaven.test.skip=true

# 上传
scp target/etl-0.0.1-SNAPSHOT.war [email protected]:/root/

# 删除原日志 | 终止服务 | 启动服务 | 查看启动日志
ssh [email protected] "rm etl.log; ps -ef | grep etl | awk '{print $2}' | xargs kill -9; nohup ./etl-0.0.1-SNAPSHOT.war > etl.log 2>&1 &; tail -f etl.log"

Configure the IDE

Run / Edit Configurations... / "+" / Bash
    1. Name 填写
    2. Script 选择 update.sh
    3. Working directory 选择 项目根目录

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324378274&siteId=291194637