main
黄海 10 months ago
parent 721a7b54b9
commit b75137a58f

@ -70,21 +70,21 @@ public class PublishUtil {
ssh.mkdir(remotePath); ssh.mkdir(remotePath);
System.out.println("正在上传Dockerfile..."); System.out.println("正在上传Dockerfile...");
ssh.upload(workingPath + "/Dockerfile", remotePath + "/Dockerfile"); ssh.upload(workingPath + "Dockerfile", remotePath + "Dockerfile");
if (!StrKit.isBlank(localLibPath)) { if (!StrKit.isBlank(localLibPath)) {
System.out.println("正在创建lib目录..."); System.out.println("正在创建lib目录...");
ssh.mkdir(remotePath + "/lib"); ssh.mkdir(remotePath + "lib");
//遍历lib目录下的文件 //遍历lib目录下的文件
for (File file : FileUtil.loopFiles(localLibPath)) { for (File file : FileUtil.loopFiles(localLibPath)) {
System.out.println("正在上传jar包" + file.getName()); System.out.println("正在上传jar包" + file.getName());
ssh.upload(file.getAbsolutePath(), remotePath + "/lib/" + file.getName()); ssh.upload(file.getAbsolutePath(), remotePath + "lib/" + file.getName());
} }
} }
if (!StrKit.isBlank(localStatic)) { if (!StrKit.isBlank(localStatic)) {
System.out.println("正在创建" + localStatic + "目录..."); System.out.println("正在创建" + localStatic + "目录...");
ssh.mkdir(remotePath + "/" + localStatic); ssh.mkdir(remotePath + localStatic);
//1、需要把目录压缩成ZIP文件 //1、需要把目录压缩成ZIP文件
// 将目录打包成ZIP文件不包含目录本身只包含目录下的文件和子目录 // 将目录打包成ZIP文件不包含目录本身只包含目录下的文件和子目录
String localFile = workingPath + localStatic + ".zip"; String localFile = workingPath + localStatic + ".zip";
@ -92,7 +92,7 @@ public class PublishUtil {
ZipUtil.zip(workingPath + localStatic, localFile, true); ZipUtil.zip(workingPath + localStatic, localFile, true);
System.out.println("静态文件打包ZIP已完成正在上传..."); System.out.println("静态文件打包ZIP已完成正在上传...");
//2、需要把ZIP文件上传 //2、需要把ZIP文件上传
ssh.upload(localFile, remotePath + "/" + localStatic + ".zip"); ssh.upload(localFile, remotePath + localStatic + ".zip");
//3、把ZIP文件在远端解压缩 //3、把ZIP文件在远端解压缩
ssh.exec("cd " + remotePath + " && unzip " + localStatic + ".zip"); ssh.exec("cd " + remotePath + " && unzip " + localStatic + ".zip");
ssh.exec("cd " + remotePath + " && rm -rf " + localStatic + ".zip"); ssh.exec("cd " + remotePath + " && rm -rf " + localStatic + ".zip");
@ -102,7 +102,7 @@ public class PublishUtil {
if (!StrKit.isBlank(localNginxConf)) { if (!StrKit.isBlank(localNginxConf)) {
System.out.println("正在上传nginx.conf..."); System.out.println("正在上传nginx.conf...");
File file = new File(localNginxConf); File file = new File(localNginxConf);
ssh.upload(file.getAbsolutePath(), remotePath + "/" + file.getName()); ssh.upload(file.getAbsolutePath(), remotePath + file.getName());
System.out.println("成功完成上传文件nginx.conf"); System.out.println("成功完成上传文件nginx.conf");
} }
//打包target为zip //打包target为zip

@ -6,15 +6,15 @@
"project": [ "project": [
{ {
"projectName": "ds-gw", "projectName": "ds-gw",
"workingPath": "D:/dsWork/dsExam/ds-gw/", "workingPath": "D:/dsWork/dsProject/ds-gw/",
"localLibPath": "", "localLibPath": "",
"localStatic": "static", "localStatic": "static",
"localNginxConf": "nginx.conf" "localNginxConf": "nginx.conf"
}, },
{ {
"projectName": "ds-base", "projectName": "ds-base",
"workingPath": "D:/dsWork/dsExam/ds-base/", "workingPath": "D:/dsWork/dsProject/ds-base/",
"localLibPath": "D:/dsWork/dsExam/ds-base/lib/", "localLibPath": "D:/dsWork/dsProject/ds-base/lib/",
"localStatic": "WebRoot", "localStatic": "WebRoot",
"localNginxConf": "" "localNginxConf": ""
} }

@ -6,15 +6,15 @@
"project": [ "project": [
{ {
"projectName": "ds-gw", "projectName": "ds-gw",
"workingPath": "D:/dsWork/dsExam/ds-gw/", "workingPath": "D:/dsWork/dsProject/ds-gw/",
"localLibPath": "", "localLibPath": "",
"localStatic": "static", "localStatic": "static",
"localNginxConf": "nginx.conf" "localNginxConf": "nginx.conf"
}, },
{ {
"projectName": "ds-base", "projectName": "ds-base",
"workingPath": "D:/dsWork/dsExam/ds-base/", "workingPath": "D:/dsWork/dsProject/ds-base/",
"localLibPath": "D:/dsWork/dsExam/ds-base/lib/", "localLibPath": "D:/dsWork/dsProject/ds-base/lib/",
"localStatic": "WebRoot", "localStatic": "WebRoot",
"localNginxConf": "" "localNginxConf": ""
} }

Loading…
Cancel
Save