|
|
|
@ -47,7 +47,7 @@ public class PublishUtil {
|
|
|
|
|
* docker tag 19a54d2204aa registry.cn-hangzhou.aliyuncs.com/yltcharge/jdk:21
|
|
|
|
|
* docker push registry.cn-hangzhou.aliyuncs.com/yltcharge/jdk:21
|
|
|
|
|
*/
|
|
|
|
|
public static void publish(String projectName, boolean isStatic, String workingPath, String localLibPath, Kv choiceWarehouse, String choiceConfig) throws Exception {
|
|
|
|
|
public static String publish(String projectName, boolean isStatic, String workingPath, String localLibPath, Kv choiceWarehouse, String choiceConfig) throws Exception {
|
|
|
|
|
System.out.println("正在生成" + projectName + "的镜像...");
|
|
|
|
|
//配置文件
|
|
|
|
|
String path = PathKit.getRootClassPath() + "\\publishImage.json";
|
|
|
|
@ -66,8 +66,11 @@ public class PublishUtil {
|
|
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
String newVersion = now.format(formatter);
|
|
|
|
|
newVersion = choiceConfig + "_" + newVersion.replace(" ", "").replace("-", "").replace(":", "");
|
|
|
|
|
|
|
|
|
|
if (!StrKit.isBlank(choiceConfig)) {
|
|
|
|
|
newVersion = choiceConfig + "_" + newVersion.replace(" ", "").replace("-", "").replace(":", "");
|
|
|
|
|
} else {
|
|
|
|
|
newVersion = newVersion.replace(" ", "").replace("-", "").replace(":", "");
|
|
|
|
|
}
|
|
|
|
|
//准备工作
|
|
|
|
|
String remotePath = "/usr/local/" + projectName + "/";
|
|
|
|
|
ssh.exec("rm -rf " + remotePath);
|
|
|
|
@ -148,6 +151,10 @@ public class PublishUtil {
|
|
|
|
|
System.out.println(cmd);
|
|
|
|
|
System.out.println("环境变量修改成功!");
|
|
|
|
|
|
|
|
|
|
//如果容器正在运行中,那么容器对应的镜像删除失败
|
|
|
|
|
cmd="docker rm -f $(docker ps -aq)";
|
|
|
|
|
ssh.exec(cmd);
|
|
|
|
|
|
|
|
|
|
//删除所有镜像
|
|
|
|
|
cmd = "docker rmi -f $(docker images -q)";
|
|
|
|
|
ssh.exec(cmd);
|
|
|
|
@ -181,6 +188,8 @@ public class PublishUtil {
|
|
|
|
|
|
|
|
|
|
ssh.disconnect();
|
|
|
|
|
System.out.println("恭喜,镜像打包成功!");
|
|
|
|
|
|
|
|
|
|
return projectName + ":" + newVersion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -204,7 +213,7 @@ public class PublishUtil {
|
|
|
|
|
// 获取目录名称
|
|
|
|
|
String dirName = file.getName();
|
|
|
|
|
// 检查目录名称是否以"ds"开头且不是"dsBuild"
|
|
|
|
|
if (dirName.startsWith("ds") && !dirName.equals("dsBuild")) {
|
|
|
|
|
if (dirName.startsWith("ds") && !dirName.equals("dsBuild") && !dirName.contains("-")) {
|
|
|
|
|
dirList.add(file.getAbsolutePath());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|