|
|
|
@ -148,12 +148,14 @@ public class PublishUtil {
|
|
|
|
|
//登录镜像仓库
|
|
|
|
|
//处理一下Dockerfile中的JDK21此用问题,因为不同的打包操作,需要登录不同的仓库,这里临时用shell修改一下
|
|
|
|
|
String remoteDockerFile = remotePath + "Dockerfile";
|
|
|
|
|
|
|
|
|
|
if (choiceWarehouse.get("id") != null) {
|
|
|
|
|
doLogin(ssh, choiceWarehouse.getStr("username"), choiceWarehouse.getStr("password"));
|
|
|
|
|
String cmd = "sed -i '1s/^FROM .*/FROM registry.cn-hangzhou.aliyuncs.com\\/" + choiceWarehouse.getStr("name") + "\\/jdk:21/' " + remoteDockerFile;
|
|
|
|
|
ssh.exec(cmd);
|
|
|
|
|
System.out.println("仓库登录成功!修改JDK21的引用镜像成功!");
|
|
|
|
|
System.out.println("仓库登录成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//修改镜像要用的配置文件
|
|
|
|
|
cmd = "sed -i 's|ENV WORKING_ENV=\"pro\"|ENV WORKING_ENV=\"" + choiceConfig + "\"|g' " + remoteDockerFile;
|
|
|
|
|
String cmd = "sed -i 's|ENV WORKING_ENV=\"pro\"|ENV WORKING_ENV=\"" + choiceConfig + "\"|g' " + remoteDockerFile;
|
|
|
|
|
ssh.exec(cmd);
|
|
|
|
|
System.out.println(cmd);
|
|
|
|
|
System.out.println("环境变量修改成功!");
|
|
|
|
@ -183,6 +185,7 @@ public class PublishUtil {
|
|
|
|
|
System.exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (choiceWarehouse.get("id") != null) {
|
|
|
|
|
System.out.println("打标签...");
|
|
|
|
|
cmd = "docker tag " + imageId + " registry.cn-hangzhou.aliyuncs.com/" + choiceWarehouse.getStr("name") + "/" + projectName + ":" + newVersion;
|
|
|
|
|
ssh.exec(cmd);
|
|
|
|
@ -192,6 +195,7 @@ public class PublishUtil {
|
|
|
|
|
System.out.println(cmd);
|
|
|
|
|
ssh.exec(cmd);
|
|
|
|
|
System.out.println("推送到远程仓库完成!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ssh.disconnect();
|
|
|
|
|
System.out.println("恭喜,镜像打包成功!");
|
|
|
|
@ -313,26 +317,34 @@ public class PublishUtil {
|
|
|
|
|
Kv kv = Kv.create();
|
|
|
|
|
while (true) {
|
|
|
|
|
redPrint("2、请选择您本次要发布的仓库:");
|
|
|
|
|
System.out.println("1:驿来特仓库 2:黄海私人仓库");
|
|
|
|
|
System.out.println("1:不上传到仓库 2:黄海私人仓库 3:驿来特仓库");
|
|
|
|
|
int choice = scanner.nextInt(); // 读取用户输入的整数
|
|
|
|
|
|
|
|
|
|
if (choice == 1) {
|
|
|
|
|
kv.set("id", 1);
|
|
|
|
|
kv.set("name", "yltcharge");
|
|
|
|
|
kv.set("username", "驿来特充电");
|
|
|
|
|
kv.set("password", "ylt5033.");
|
|
|
|
|
System.out.println("您选择的仓库是:驿来特仓库");
|
|
|
|
|
} else {
|
|
|
|
|
kv.set("id", null);
|
|
|
|
|
kv.set("name", null);
|
|
|
|
|
kv.set("username", null);
|
|
|
|
|
kv.set("password", null);
|
|
|
|
|
System.out.println("您选择的仓库是:不上传到仓库");
|
|
|
|
|
}
|
|
|
|
|
if (choice == 2) {
|
|
|
|
|
kv.set("id", 2);
|
|
|
|
|
kv.set("name", "dsideal");
|
|
|
|
|
kv.set("username", "东师黄海");
|
|
|
|
|
kv.set("password", "DsideaL4r5t6y7u");
|
|
|
|
|
System.out.println("您选择的仓库是:黄海私人仓库");
|
|
|
|
|
}
|
|
|
|
|
if (choice == 1 || choice == 2) {
|
|
|
|
|
if (choice == 3) {
|
|
|
|
|
kv.set("id", 3);
|
|
|
|
|
kv.set("name", "yltcharge");
|
|
|
|
|
kv.set("username", "驿来特充电");
|
|
|
|
|
kv.set("password", "ylt5033.");
|
|
|
|
|
System.out.println("您选择的仓库是:驿来特仓库");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (choice == 1 || choice == 2 || choice == 3) {
|
|
|
|
|
break; // 如果输入正确,退出循环
|
|
|
|
|
} else {
|
|
|
|
|
System.out.println("输入不正确,请输入1 或者 2 !"); // 提示用户输入不正确
|
|
|
|
|
System.out.println("输入不正确,请输入1, 2 或者 3 !"); // 提示用户输入不正确
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return kv;
|
|
|
|
|