mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-12-02 11:58:01 +08:00
fix 容器构建查询可用标签容器相关提示
This commit is contained in:
parent
49e732718b
commit
5487cf9461
@ -17,6 +17,7 @@
|
||||
5. 【server】优化 docker 管理裁剪功能独立菜单
|
||||
6. 【server】修复 资产管理未记录操作日志的问题
|
||||
7. 【server】优化 操作日志存储用户名、工作空间名字段
|
||||
8. 【server】优化 容器构建查询可用标签容器相关提示
|
||||
|
||||
------
|
||||
|
||||
|
@ -753,11 +753,11 @@ public class BuildExecuteService {
|
||||
List<DockerInfoModel> dockerInfoModels = buildExecuteService
|
||||
.dockerInfoService
|
||||
.queryByTag(buildInfoModel.getWorkspaceId(), fromTag);
|
||||
DockerInfoModel dockerInfoModel = CollUtil.getFirst(dockerInfoModels);
|
||||
Assert.notNull(dockerInfoModel, "没有可用的 docker server");
|
||||
logRecorder.system("use docker {}", dockerInfoModel.getName());
|
||||
Map<String, Object> map = buildExecuteService.machineDockerServer.dockerParameter(dockerInfoModels);
|
||||
Assert.notNull(map, "没有可用的 docker server");
|
||||
logRecorder.system("use docker {}", map.get("name"));
|
||||
String workingDir = "/home/jpom/";
|
||||
Map<String, Object> map = buildExecuteService.machineDockerServer.dockerParameter(dockerInfoModel);
|
||||
|
||||
map.put("runsOn", dockerYmlDsl.getRunsOn());
|
||||
map.put("workingDir", workingDir);
|
||||
map.put("tempDir", JpomApplication.getInstance().getTempPath());
|
||||
|
@ -147,7 +147,7 @@ public class ReleaseManage {
|
||||
} else if (releaseMethod == BuildReleaseMethod.LocalCommand.getCode()) {
|
||||
return this.localCommand();
|
||||
} else if (releaseMethod == BuildReleaseMethod.DockerImage.getCode()) {
|
||||
this.doDockerImage();
|
||||
return this.doDockerImage();
|
||||
} else if (releaseMethod == BuildReleaseMethod.No.getCode()) {
|
||||
return true;
|
||||
} else {
|
||||
@ -199,7 +199,7 @@ public class ReleaseManage {
|
||||
}).collect(Collectors.joining(StrUtil.COMMA));
|
||||
}
|
||||
|
||||
private void doDockerImage() {
|
||||
private boolean doDockerImage() {
|
||||
// 生成临时目录
|
||||
File tempPath = FileUtil.file(JpomApplication.getInstance().getTempPath(), "build_temp", "docker_image", this.buildExtraModule.getId() + StrUtil.DASHED + this.buildNumberId);
|
||||
try {
|
||||
@ -221,7 +221,7 @@ public class ReleaseManage {
|
||||
File dockerfile = FileUtil.file(tempPath, dockerFile);
|
||||
if (!FileUtil.isFile(dockerfile)) {
|
||||
logRecorder.systemError("仓库目录下没有找到 Dockerfile 文件: {}", dockerFile);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
File baseDir = FileUtil.file(tempPath, list.size() == 1 ? StrUtil.SLASH : CollUtil.get(list, 0));
|
||||
//
|
||||
@ -230,10 +230,10 @@ public class ReleaseManage {
|
||||
List<DockerInfoModel> dockerInfoModels = buildExecuteService
|
||||
.dockerInfoService
|
||||
.queryByTag(this.buildExtraModule.getWorkspaceId(), fromTag);
|
||||
DockerInfoModel dockerInfoModel = CollUtil.getFirst(dockerInfoModels);
|
||||
if (dockerInfoModel == null) {
|
||||
Map<String, Object> map = buildExecuteService.machineDockerServer.dockerParameter(dockerInfoModels);
|
||||
if (map == null) {
|
||||
logRecorder.systemError("没有可用的 docker server");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
//String dockerBuildArgs = this.buildExtraModule.getDockerBuildArgs();
|
||||
for (DockerInfoModel infoModel : dockerInfoModels) {
|
||||
@ -244,9 +244,7 @@ public class ReleaseManage {
|
||||
if (pushToRepository != null && pushToRepository) {
|
||||
List<String> repositoryList = StrUtil.splitTrim(dockerTag, StrUtil.COMMA);
|
||||
for (String repositoryItem : repositoryList) {
|
||||
logRecorder.system("start push to repository in({}),{} {}", dockerInfoModel.getName(), StrUtil.emptyToDefault(dockerInfoModel.getRegistryUrl(), StrUtil.EMPTY), repositoryItem);
|
||||
Map<String, Object> map = buildExecuteService.machineDockerServer.dockerParameter(dockerInfoModel);
|
||||
//dockerInfoModel.toParameter();
|
||||
logRecorder.system("start push to repository in({}),{} {}", map.get("name"), StrUtil.emptyToDefault((String) map.get("registryUrl"), StrUtil.EMPTY), repositoryItem);
|
||||
//
|
||||
map.put("repository", repositoryItem);
|
||||
Consumer<String> logConsumer = s -> logRecorder.info(s);
|
||||
@ -264,6 +262,7 @@ public class ReleaseManage {
|
||||
} finally {
|
||||
CommandUtil.systemFastDel(tempPath);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateSwarmService(String dockerTag, String swarmId, String serviceName) {
|
||||
|
@ -284,7 +284,7 @@ public class BuildInfoController extends BaseServerController {
|
||||
//
|
||||
String workspaceId = dockerInfoService.getCheckUserWorkspace(request);
|
||||
int count = dockerInfoService.countByTag(workspaceId, fromTag);
|
||||
Assert.state(count > 0, "docker tag 填写不正确,没有找到任何docker");
|
||||
Assert.state(count > 0, fromTag + " 没有找到任何 docker。可能docker tag 填写不正确,需要为 docker 配置标签");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ public class MachineDockerModel extends BaseGroupNameModel {
|
||||
public Map<String, Object> toParameter() {
|
||||
Map<String, Object> parameter = new HashMap<>(10);
|
||||
parameter.put("dockerHost", this.getHost());
|
||||
// parameter.put("apiVersion", this.getApiVersion());
|
||||
parameter.put("name", this.getName());
|
||||
parameter.put("registryUsername", this.getRegistryUsername());
|
||||
parameter.put("registryPassword", this.getRegistryPassword());
|
||||
parameter.put("registryEmail", this.getRegistryEmail());
|
||||
|
@ -270,6 +270,26 @@ public class MachineDockerServer extends BaseDbService<MachineDockerModel> imple
|
||||
return machineDockerModel.toParameter();
|
||||
}
|
||||
|
||||
/**
|
||||
* 跟进 docker 列表找到一个可用的 docker 信息
|
||||
*
|
||||
* @param dockerInfoModels docker 列表
|
||||
* @return map
|
||||
*/
|
||||
public Map<String, Object> dockerParameter(List<DockerInfoModel> dockerInfoModels) {
|
||||
for (DockerInfoModel dockerInfoModel : dockerInfoModels) {
|
||||
String machineDockerId = dockerInfoModel.getMachineDockerId();
|
||||
MachineDockerModel machineDockerModel = this.getByKey(machineDockerId, false);
|
||||
if (machineDockerModel != null) {
|
||||
Integer status = machineDockerModel.getStatus();
|
||||
if (status != null && status == 1) {
|
||||
return machineDockerModel.toParameter();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过集群 id 获取 docker 管理参数
|
||||
*
|
||||
@ -300,6 +320,9 @@ public class MachineDockerServer extends BaseDbService<MachineDockerModel> imple
|
||||
}
|
||||
|
||||
public MachineDockerModel tryMachineDockerBySwarmId(String swarmId) {
|
||||
if (StrUtil.isEmpty(swarmId)) {
|
||||
return null;
|
||||
}
|
||||
//
|
||||
MachineDockerModel dockerInfoModel = new MachineDockerModel();
|
||||
dockerInfoModel.setSwarmId(swarmId);
|
||||
|
Loading…
Reference in New Issue
Block a user