feat(deploy): 新增SIT环境部署自动化测试脚本

- 实现基于SSH连接的远程文件传输和命令执行功能
- 支持判断远程文件是否存在及MD5校验避免重复上传
- 完成jar包及lib目录自动上传处理
- 执行远程脚本重启服务
- 增加详细日志打印,支持时间戳和颜色区分信息与错误
- 封装SSH会话及SFTP操作工具类,提高复用性和可维护性
This commit is contained in:
曹鹏飞 2026-04-10 15:56:53 +08:00
parent 383fbed6b4
commit 03808c145c
1 changed files with 4 additions and 4 deletions

View File

@ -18,10 +18,10 @@ import java.util.List;
@Slf4j
public class DeploySitTest {
private static final String serviceName = "admin";
private static final String serviceName = "qms";
private static final String localPath = System.getProperty("user.dir") + "//target//";
private static final String remotePath = "/mnt/app/qms/" + serviceName + "/";
private static final String jarName = "nflg-qms-" + serviceName + "-1.0.0-SNAPSHOT.jar";
private static final String remotePath = "/mnt/app/" + serviceName + "/admin/";
private static final String jarName = "nflg-" + serviceName + "-admin-1.0.0-SNAPSHOT.jar";
@Test
public void DeployToSit() throws Exception {
@ -32,7 +32,7 @@ public class DeploySitTest {
//处理字体目录
// handleDir(sshUtil, localPath, remotePath, "fonts");
//处理lib目录
// handleDir(sshUtil, localPath, remotePath, "lib");
handleDir(sshUtil, localPath, remotePath, "lib");
//执行脚本启动服务
sshUtil.exec("cd " + remotePath + " && ./restart.sh");
sshUtil.disconnect();