reghao 1 день тому
батько
коміт
48c4026382
25 змінених файлів з 243 додано та 281 видалено
  1. 1 1
      mgr/src/main/java/cn/reghao/devops/mgr/ops/app/controller/AppConfigController.java
  2. 1 1
      mgr/src/main/java/cn/reghao/devops/mgr/ops/app/db/query/AppBuildQuery.java
  3. 49 0
      mgr/src/main/java/cn/reghao/devops/mgr/ops/app/db/query/AppBuildRepository.java
  4. 4 4
      mgr/src/main/java/cn/reghao/devops/mgr/ops/app/db/query/impl/AppBuildQueryImpl.java
  5. 2 3
      mgr/src/main/java/cn/reghao/devops/mgr/ops/app/db/query/impl/AppDeployQueryImpl.java
  6. 10 14
      mgr/src/main/java/cn/reghao/devops/mgr/ops/app/model/dto/AppConfigDto.java
  7. 7 8
      mgr/src/main/java/cn/reghao/devops/mgr/ops/app/model/dto/AppConfigUpdateDto.java
  8. 7 28
      mgr/src/main/java/cn/reghao/devops/mgr/ops/app/model/po/AppConfig.java
  9. 3 5
      mgr/src/main/java/cn/reghao/devops/mgr/ops/app/model/vo/AppConfigDetail.java
  10. 2 4
      mgr/src/main/java/cn/reghao/devops/mgr/ops/app/model/vo/AppConfigVO.java
  11. 0 2
      mgr/src/main/java/cn/reghao/devops/mgr/ops/app/model/vo/AppDeployConfigVO.java
  12. 0 1
      mgr/src/main/java/cn/reghao/devops/mgr/ops/app/model/vo/AppNodeCount.java
  13. 37 67
      mgr/src/main/java/cn/reghao/devops/mgr/ops/app/service/impl/AppBuildServiceImpl.java
  14. 4 0
      mgr/src/main/java/cn/reghao/devops/mgr/ops/build/model/constant/EnvType.java
  15. 16 7
      mgr/src/main/java/cn/reghao/devops/mgr/ops/build/service/BuildConfigChecker.java
  16. 4 4
      mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/controller/BuildDeployController.java
  17. 2 2
      mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/db/repository/AppDeployingRepository.java
  18. 2 4
      mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/model/vo/AppBuildingVO.java
  19. 1 2
      mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/model/vo/AppRunning.java
  20. 2 4
      mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/model/vo/AppRunningNode.java
  21. 1 6
      mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/service/impl/DeployAppImpl.java
  22. 3 3
      mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/tool/repo/CodeUpdater.java
  23. 84 90
      mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/tool/repo/GitClient.java
  24. 1 2
      mgr/src/main/java/cn/reghao/devops/mgr/ops/machine/service/impl/MachineQueryImpl.java
  25. 0 19
      mgr/src/test/java/devops/GitTest.java

+ 1 - 1
mgr/src/main/java/cn/reghao/devops/mgr/ops/app/controller/AppConfigController.java

@@ -137,7 +137,7 @@ public class AppConfigController {
 
     @Operation(summary = "添加应用配置", description = "N")
     @PostMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE)
-    public String addAppConfig(@Validated AppConfigDto appConfigDto) {
+    public String addAppConfig(@RequestBody @Validated AppConfigDto appConfigDto) {
         Result result = appBuildService.createAppBuild(appConfigDto);
         return WebResult.result(result);
     }

+ 1 - 1
mgr/src/main/java/cn/reghao/devops/mgr/ops/app/db/query/AppBuildQuery.java

@@ -30,7 +30,7 @@ public interface AppBuildQuery {
     List<AppConfig> findAllByPackerConfig(PackerConfig packerConfig);
 
     Page<AppBuildingVO> getByPage(String appEnv, String appType, Pageable pageable);
-    Page<AppBuildingVO> queryByAppName(Map<String, String> kv, Pageable pageable);
+    Page<AppBuildingVO> queryByAppId(Map<String, String> kv, Pageable pageable);
     Page<BuildLogVO> buildLogVOs(String appId, Pageable pageable);
     AppBuilding getAppBuilding(String appId);
     AppBuilding getAppBuildingByBuildId(String buildId);

+ 49 - 0
mgr/src/main/java/cn/reghao/devops/mgr/ops/app/db/query/AppBuildRepository.java

@@ -0,0 +1,49 @@
+package cn.reghao.devops.mgr.ops.app.db.query;
+
+import cn.reghao.devops.mgr.ops.app.db.repository.AppConfigRepository;
+import cn.reghao.devops.mgr.ops.app.model.po.AppConfig;
+import cn.reghao.devops.mgr.ops.builder.db.repository.AppBuildingRepository;
+import cn.reghao.devops.mgr.ops.builder.db.repository.BuildLogRepository;
+import cn.reghao.devops.mgr.ops.builder.model.po.AppBuilding;
+import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * @author reghao
+ * @date 2026-03-20 15:22:54
+ */
+@Repository
+public class AppBuildRepository {
+    private final AppConfigRepository appConfigRepository;
+    private final AppBuildingRepository buildingRepository;
+    private final BuildLogRepository buildLogRepository;
+
+    public AppBuildRepository(AppConfigRepository appConfigRepository, AppBuildingRepository buildingRepository,
+                              BuildLogRepository buildLogRepository) {
+        this.appConfigRepository = appConfigRepository;
+        this.buildingRepository = buildingRepository;
+        this.buildLogRepository = buildLogRepository;
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public void save(AppConfig appConfig) {
+        appConfig = appConfigRepository.save(appConfig);
+        AppBuilding appBuilding = new AppBuilding(appConfig);
+        buildingRepository.save(appBuilding);
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public void update(AppConfig appConfig) {
+        AppBuilding appBuilding = buildingRepository.findAllByAppConfig_AppId(appConfig.getAppId());
+        appBuilding.setAppConfig(appConfig);
+
+        appConfigRepository.save(appConfig);
+        buildingRepository.save(appBuilding);
+    }
+
+    public void deleteAppBuild(String appId) {
+        buildLogRepository.deleteByAppConfig_AppId(appId);
+        buildingRepository.deleteByAppConfig_AppId(appId);
+        appConfigRepository.deleteByAppId(appId);
+    }
+}

+ 4 - 4
mgr/src/main/java/cn/reghao/devops/mgr/ops/app/db/query/impl/AppBuildQueryImpl.java

@@ -57,9 +57,9 @@ public class AppBuildQueryImpl implements AppBuildQuery {
     public Page<AppConfig> queryByFields(Map<String, String> kv, Pageable pageable) {
         Specification<AppConfig> specification = (root, query, cb) -> {
             List<Predicate> predicates = new ArrayList<>();
-            String appName = kv.get("appName");
-            if (appName != null && !appName.isBlank()) {
-                predicates.add(cb.like(root.get("appName"), "%" + appName + "%"));
+            String appId = kv.get("appId");
+            if (appId != null && !appId.isBlank()) {
+                predicates.add(cb.like(root.get("appId"), "%" + appId + "%"));
             }
 
             String appType = kv.get("appType");
@@ -143,7 +143,7 @@ public class AppBuildQueryImpl implements AppBuildQuery {
     }
 
     @Override
-    public Page<AppBuildingVO> queryByAppName(Map<String, String> kv, Pageable pageable) {
+    public Page<AppBuildingVO> queryByAppId(Map<String, String> kv, Pageable pageable) {
         Page<AppConfig> page = queryByFields(kv, pageable);
         return page.map(appConfig -> {
             AppBuilding appBuilding = buildingRepository.findAllByAppConfig_AppId(appConfig.getAppId());

+ 2 - 3
mgr/src/main/java/cn/reghao/devops/mgr/ops/app/db/query/impl/AppDeployQueryImpl.java

@@ -122,8 +122,7 @@ public class AppDeployQueryImpl implements AppDeployQuery {
 
             AppConfig appConfig = appBuilding.getAppConfig();
             String appId = appConfig.getAppId();
-            String appName = appConfig.getAppName();
-            String bindPorts = appConfig.getBindPorts();
+            int httpPort = appConfig.getHttpPort();
 
             String packagePath = "N/A";
             BuildLog buildLog = appBuildQuery.getAppBuilding(appId).getBuildLog();
@@ -134,7 +133,7 @@ public class AppDeployQueryImpl implements AppDeployQuery {
             int totalDeployed = appNodeCount.getCount().intValue();
             int totalRunning = totalDeployed;
             int totalStopped = totalDeployed-totalRunning;
-            return new AppRunning(appId, appName, bindPorts, packagePath, totalDeployed, totalRunning, totalStopped);
+            return new AppRunning(appId, httpPort, packagePath, totalDeployed, totalRunning, totalStopped);
         }).collect(Collectors.toList());
         return new PageImpl<>(list, pageable, page.getTotalElements());
     }

+ 10 - 14
mgr/src/main/java/cn/reghao/devops/mgr/ops/app/model/dto/AppConfigDto.java

@@ -1,6 +1,7 @@
 package cn.reghao.devops.mgr.ops.app.model.dto;
 
 import cn.reghao.devops.mgr.ops.app.model.constant.AppType;
+import cn.reghao.devops.mgr.ops.build.model.constant.EnvType;
 import cn.reghao.jutil.jdk.web.validator.ValidEnum;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
@@ -19,30 +20,25 @@ import jakarta.validation.constraints.Pattern;
 @Setter
 @Getter
 public class AppConfigDto {
-    @Pattern(regexp = "^\\S*$", message = "应用 ID 不能包含空白符")
-    @Length(max = 20, message = "应用 ID 的最大长度为 20 个字符")
-    private String appId;
-    @NotBlank(message = "应用名字不能为空白符")
-    @Length(min = 2, max = 20, message = "应用名字的长度为 2 ~ 20 个字符")
-    private String appName;
     @NotNull
     @ValidEnum(value = AppType.class, message = "请选择正确的应用类型")
     private String appType;
     @NotBlank(message = "必须指定应用环境")
+    @NotNull
+    @ValidEnum(value = EnvType.class, message = "请选择正确的环境")
     private String env;
     @NotBlank(message = "必须指定应用仓库")
     private String appRepo;
     @NotBlank(message = "必须指定仓库分支")
     private String repoBranch;
-    private String appRootPath;
-    private String bindPorts;
+    private Integer httpPort;
 
     // buildConfig
-    @NotBlank(message = "必须指定仓库认证")
-    private String repoAuthConfig;
-    @NotBlank(message = "必须指定编译配置")
-    private String compilerConfig;
-    @NotBlank(message = "必须指定打包配置")
-    private String packerConfig;
+    @NotNull(message = "必须指定仓库认证")
+    private Integer repoAuthConfigId;
+    @NotNull(message = "必须指定编译配置")
+    private Integer compilerConfigId;
+    @NotNull(message = "必须指定打包配置")
+    private Integer packerConfigId;
     private String dockerfile;
 }

+ 7 - 8
mgr/src/main/java/cn/reghao/devops/mgr/ops/app/model/dto/AppConfigUpdateDto.java

@@ -1,5 +1,6 @@
 package cn.reghao.devops.mgr.ops.app.model.dto;
 
+import jakarta.validation.constraints.NotNull;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
 import lombok.Setter;
@@ -15,17 +16,15 @@ import jakarta.validation.constraints.NotBlank;
 @Getter
 public class AppConfigUpdateDto {
     private String appId;
-    @NotBlank(message = "必须指定应用名字")
-    private String appName;
     @NotBlank(message = "必须指定仓库分支")
     private String repoBranch;
 
     // buildConfig
-    @NotBlank(message = "必须指定仓库认证")
-    private String repoAuthConfig;
-    @NotBlank(message = "必须指定编译配置")
-    private String compilerConfig;
-    @NotBlank(message = "必须指定打包配置")
-    private String packerConfig;
+    @NotNull(message = "必须指定仓库认证")
+    private Integer repoAuthConfigId;
+    @NotNull(message = "必须指定编译配置")
+    private Integer compilerConfigId;
+    @NotNull(message = "必须指定打包配置")
+    private Integer packerConfigId;
     private String dockerfile;
 }

+ 7 - 28
mgr/src/main/java/cn/reghao/devops/mgr/ops/app/model/po/AppConfig.java

@@ -34,8 +34,8 @@ public class AppConfig extends BaseEntity implements Cloneable {
     @NotBlank(message = "应用 ID 不能为空字符串")
     @Length(min = 2, max = 32, message = "应用 ID 仅可包含数字, 小写字母和短横线(-)等字符, 长度为 2 ~ 32 个字符")
     private String appId;
-    @NotBlank(message = "应用名字不能为空白字符串")
-    private String appName;
+    @NotBlank(message = "项目名不能为空白字符串")
+    private String projName;
     @NotNull
     @ValidEnum(value = AppType.class, message = "请选择正确的应用类型")
     private String appType;
@@ -47,14 +47,7 @@ public class AppConfig extends BaseEntity implements Cloneable {
     @NotNull
     @NotBlank(message = "仓库分支不能为空白字符串")
     private String repoBranch;
-
-    /* 构建配置 */
-    @Deprecated
-    private String projDirname;
-    @NotNull
-    @NotBlank(message = "应用根目录不能为空白字符串")
-    private String appRootPath;
-    private String bindPorts;
+    private Integer httpPort;
     private String healthCheck;
     private String domains;
 
@@ -81,19 +74,15 @@ public class AppConfig extends BaseEntity implements Cloneable {
         return super.clone();
     }
 
-    public AppConfig(AppConfigDto appConfigDto, String projDirname, BuildConfig buildConfig) {
-        this.appId = appConfigDto.getAppId();
-        this.appName = appConfigDto.getAppName();
+    public AppConfig(String appId, AppConfigDto appConfigDto, String projName, BuildConfig buildConfig) {
+        this.appId = appId;
+        this.projName = projName;
         this.appType = appConfigDto.getAppType();
         this.env = appConfigDto.getEnv();
         this.appRepo = appConfigDto.getAppRepo();
         this.repoBranch = appConfigDto.getRepoBranch();
-
-        this.projDirname = projDirname;
-        this.appRootPath = appConfigDto.getAppRootPath();
-        this.bindPorts = appConfigDto.getBindPorts();
+        this.httpPort = appConfigDto.getHttpPort() == null ? 0 :  appConfigDto.getHttpPort();
         this.healthCheck = "";
-
         this.repoAuthConfig = buildConfig.getRepoAuth();
         this.compilerConfig = buildConfig.getCompiler();
         this.packerConfig = buildConfig.getPacker();
@@ -101,21 +90,11 @@ public class AppConfig extends BaseEntity implements Cloneable {
     }
 
     public AppConfig update(AppConfigUpdateDto appConfigUpdateDto, BuildConfig buildConfig) {
-        this.appName = appConfigUpdateDto.getAppName();
         this.repoBranch = appConfigUpdateDto.getRepoBranch();
-
         this.repoAuthConfig = buildConfig.getRepoAuth();
         this.compilerConfig = buildConfig.getCompiler();
         this.packerConfig = buildConfig.getPacker();
         this.dockerfile = appConfigUpdateDto.getDockerfile();
         return this;
     }
-
-    public AppDto getAppDto() {
-        BuildConfigDto buildConfigDto = new BuildConfigDto(this.repoAuthConfig.getRepoAuth(),
-                this.compilerConfig.getCompilerDto(), this.packerConfig.getPackerDto(), this.packerConfig.getDockerAuth());
-
-        return new AppDto(this.appId, this.env, this.appType, this.appRepo, this.repoBranch, this.projDirname,
-                this.appRootPath, this.dockerfile, buildConfigDto);
-    }
 }

+ 3 - 5
mgr/src/main/java/cn/reghao/devops/mgr/ops/app/model/vo/AppConfigDetail.java

@@ -8,7 +8,6 @@ import cn.reghao.devops.mgr.ops.app.model.po.AppConfig;
  */
 public class AppConfigDetail {
     private String appId;
-    private String appName;
     private String appType;
     private String env;
     private String appRepo;
@@ -17,7 +16,7 @@ public class AppConfigDetail {
     /* 构建配置 */
     private String projDirname;
     private String appRootPath;
-    private String bindPorts;
+    private int httpPort;
     private String healthCheck;
     private String domains;
 
@@ -29,13 +28,12 @@ public class AppConfigDetail {
 
     public AppConfigDetail(AppConfig appConfig) {
         this.appId = appConfig.getAppId();
-        this.appName = appConfig.getAppName();
         this.appType = appConfig.getAppType();
         this.env = appConfig.getEnv();
         this.appRepo = appConfig.getAppRepo();
         this.repoBranch = appConfig.getRepoBranch();
-        this.appRootPath = appConfig.getAppRootPath();
-        this.bindPorts = appConfig.getBindPorts();
+        this.appRootPath = "appConfig.getAppRootPath()";
+        this.httpPort = appConfig.getHttpPort();
 
         this.repoAuthConfig = appConfig.getRepoAuthConfig().getName();
         this.compilerConfig = appConfig.getCompilerConfig().getName();

+ 2 - 4
mgr/src/main/java/cn/reghao/devops/mgr/ops/app/model/vo/AppConfigVO.java

@@ -13,10 +13,9 @@ import lombok.NoArgsConstructor;
 public class AppConfigVO {
     private int id;
     private String appId;
-    private String appName;
     private String appType;
     private String repoBranch;
-    private String bindPorts;
+    private int httpPort;
     private int totalDeployNodes;
     private int totalDomains;
     private String packType;
@@ -24,10 +23,9 @@ public class AppConfigVO {
     public AppConfigVO(AppConfig appConfig, int totalDeployNodes, int totalDomains) {
         this.id = appConfig.getId();
         this.appId = appConfig.getAppId();
-        this.appName = appConfig.getAppName();
         this.appType = appConfig.getAppType();
         this.repoBranch = appConfig.getRepoBranch();
-        this.bindPorts = appConfig.getBindPorts();
+        this.httpPort = appConfig.getHttpPort();
         this.totalDeployNodes = totalDeployNodes;
         this.totalDomains = totalDomains;
         this.packType = appConfig.getPackerConfig().getType();

+ 0 - 2
mgr/src/main/java/cn/reghao/devops/mgr/ops/app/model/vo/AppDeployConfigVO.java

@@ -13,7 +13,6 @@ import lombok.Data;
 public class AppDeployConfigVO {
     private Integer appDeployConfigId;
     private String appId;
-    private String appName;
     private String machineId;
     private String machineIpv4;
     private String packType;
@@ -24,7 +23,6 @@ public class AppDeployConfigVO {
     public AppDeployConfigVO(AppDeployConfig appDeployConfig) {
         this.appDeployConfigId = appDeployConfig.getId();
         this.appId = appDeployConfig.getAppConfig().getAppId();
-        this.appName = appDeployConfig.getAppConfig().getAppName();
         this.machineId = appDeployConfig.getMachineInfo().getMachineId();
         this.machineIpv4 = appDeployConfig.getMachineInfo().getMachineIpv4();
         this.packType = appDeployConfig.getAppConfig().getPackerConfig().getType();

+ 0 - 1
mgr/src/main/java/cn/reghao/devops/mgr/ops/app/model/vo/AppNodeCount.java

@@ -11,6 +11,5 @@ import lombok.Data;
 @AllArgsConstructor
 public class AppNodeCount {
     private String appId;
-    private String appName;
     private Long count;
 }

+ 37 - 67
mgr/src/main/java/cn/reghao/devops/mgr/ops/app/service/impl/AppBuildServiceImpl.java

@@ -1,19 +1,19 @@
 package cn.reghao.devops.mgr.ops.app.service.impl;
 
-import cn.reghao.devops.mgr.ops.builder.db.repository.AppBuildingRepository;
+import cn.reghao.devops.mgr.ops.app.db.query.AppBuildRepository;
+import cn.reghao.devops.mgr.ops.build.model.po.RepoAuthConfig;
 import cn.reghao.devops.mgr.ops.app.db.repository.AppConfigRepository;
 import cn.reghao.devops.mgr.ops.builder.db.repository.BuildLogRepository;
 import cn.reghao.devops.mgr.ops.app.model.dto.AppConfigDto;
 import cn.reghao.devops.mgr.ops.app.model.dto.AppConfigUpdateDto;
 import cn.reghao.devops.mgr.ops.app.model.dto.CopyAppDto;
-import cn.reghao.devops.mgr.ops.builder.model.po.AppBuilding;
 import cn.reghao.devops.mgr.ops.app.model.po.AppConfig;
 import cn.reghao.devops.mgr.ops.app.service.AppBuildService;
 import cn.reghao.devops.mgr.ops.app.service.AppDeployService;
 import cn.reghao.devops.mgr.ops.build.model.vo.BuildConfig;
 import cn.reghao.devops.mgr.ops.build.service.BuildConfigChecker;
 import cn.reghao.devops.mgr.ops.builder.model.LocalBuildDir;
-import cn.reghao.devops.mgr.ops.build.model.constant.RepoType;
+import cn.reghao.devops.mgr.ops.builder.tool.repo.GitClient;
 import cn.reghao.jutil.jdk.web.result.Result;
 import cn.reghao.jutil.jdk.web.result.ResultStatus;
 import lombok.extern.slf4j.Slf4j;
@@ -34,69 +34,53 @@ import java.time.LocalDateTime;
 @Service
 public class AppBuildServiceImpl implements AppBuildService {
     private final AppConfigRepository appConfigRepository;
-    private final AppBuildingRepository buildingRepository;
     private final BuildLogRepository buildLogRepository;
     private final BuildConfigChecker buildConfigChecker;
     private final AppDeployService appDeployService;
+    private final GitClient gitClient;
+    private final AppBuildRepository appBuildRepository;
 
-    public AppBuildServiceImpl(AppConfigRepository appConfigRepository, AppBuildingRepository buildingRepository,
-                               BuildLogRepository buildLogRepository, BuildConfigChecker buildConfigChecker,
-                               AppDeployService appDeployService) {
+    public AppBuildServiceImpl(AppConfigRepository appConfigRepository, BuildLogRepository buildLogRepository,
+                               BuildConfigChecker buildConfigChecker, AppDeployService appDeployService,
+                               GitClient gitClient, AppBuildRepository appBuildRepository) {
         this.appConfigRepository = appConfigRepository;
-        this.buildingRepository = buildingRepository;
         this.buildLogRepository = buildLogRepository;
         this.buildConfigChecker = buildConfigChecker;
         this.appDeployService = appDeployService;
+        this.gitClient = gitClient;
+        this.appBuildRepository = appBuildRepository;
     }
 
     @Override
     public Result createAppBuild(AppConfigDto appConfigDto) {
-        String appId = appConfigDto.getAppId();
+        RepoAuthConfig repoAuthConfig = buildConfigChecker.getRepoAuthConfig(appConfigDto.getRepoAuthConfigId());
+        String appRepo = StringUtils.trimAllWhitespace(appConfigDto.getAppRepo());
+        String repoBranch = appConfigDto.getRepoBranch();
+        boolean repoExist = gitClient.checkRemoteBranch(appRepo, repoBranch, repoAuthConfig);
+        if (!repoExist) {
+            String msg = String.format("仓库 %s 或分支 %s 不存在", appRepo, repoBranch);
+            return Result.result(ResultStatus.FAIL, msg);
+        }
+
+        String env = appConfigDto.getEnv();
+        String projName0 = appRepo.substring(appRepo.lastIndexOf("/")+1);
+        String projName = projName0.replace(".git", "");
+        String appId = String.format("%s_%s", projName, env);
         AppConfig appConfig = appConfigRepository.findByAppId(appId);
         if (appConfig != null) {
             String msg = String.format("%s 已存在", appId);
             return Result.result(ResultStatus.FAIL, msg);
         }
 
-        String appRepo = appConfigDto.getAppRepo();
-        String appRepo1 = StringUtils.trimAllWhitespace(appRepo);
-        appConfigDto.setAppRepo(appRepo1);
-
-        String repoAuthName = appConfigDto.getRepoAuthConfig();
-        String compilerName = appConfigDto.getCompilerConfig();
-        String packerName = appConfigDto.getPackerConfig();
-        try {
-            BuildConfig buildConfig = buildConfigChecker.checkAndGet(repoAuthName, compilerName, packerName);
-            String projDirname = getProjDirname(appConfigDto.getAppRepo(), buildConfig.getRepoAuth().getType());
-
-            appConfig = new AppConfig(appConfigDto, projDirname, buildConfig);
-            create(appConfig);
-        } catch (Exception e) {
-            return Result.result(ResultStatus.FAIL, e.getMessage());
-        }
-
+        int repoAuthId = appConfigDto.getRepoAuthConfigId();
+        int compilerId = appConfigDto.getCompilerConfigId();
+        int packerId = appConfigDto.getPackerConfigId();
+        BuildConfig buildConfig = buildConfigChecker.checkAndGet(repoAuthId, compilerId, packerId);
+        appConfig = new AppConfig(appId, appConfigDto, projName, buildConfig);
+        appBuildRepository.save(appConfig);
         return Result.result(ResultStatus.SUCCESS);
     }
 
-    private String getProjDirname(String appRepo, String repoType) {
-        int index = appRepo.lastIndexOf("/");
-        String projDir;
-        if (repoType.equals(RepoType.git.getName())) {
-            projDir = appRepo.substring(index+1).replace(".git", "");
-        } else {
-            projDir = appRepo.substring(index+1);
-        }
-
-        return projDir;
-    }
-
-    @Transactional(rollbackFor = Exception.class)
-    public void create(AppConfig appConfig) {
-        appConfig = appConfigRepository.save(appConfig);
-        AppBuilding appBuilding = new AppBuilding(appConfig);
-        buildingRepository.save(appBuilding);
-    }
-
     @Override
     public Result createByCopy(CopyAppDto copyAppDto) {
         String appId = copyAppDto.getAppId();
@@ -120,13 +104,10 @@ public class AppBuildServiceImpl implements AppBuildService {
             toApp.setCreateTime(LocalDateTime.now());
             toApp.setUpdateTime(LocalDateTime.now());
             toApp.setAppId(copyAppDto.getNewAppId());
-            toApp.setAppName(copyAppDto.getNewAppId());
             toApp.setEnv(copyAppDto.getNewEnv());
             toApp.setRepoBranch(copyAppDto.getNewRepoBranch());
             toApp = appConfigRepository.save(toApp);
-
-            AppBuilding appBuilding = new AppBuilding(toApp);
-            buildingRepository.save(appBuilding);
+            appBuildRepository.save(toApp);
             return Result.result(ResultStatus.SUCCESS);
         } catch (Exception e) {
             return Result.fail(e.getMessage());
@@ -150,21 +131,12 @@ public class AppBuildServiceImpl implements AppBuildService {
             }
         }
 
-        String repoAuthName = appConfigUpdateDto.getRepoAuthConfig();
-        String compilerName = appConfigUpdateDto.getCompilerConfig();
-        String packerName = appConfigUpdateDto.getPackerConfig();
-        try {
-            BuildConfig buildConfig = buildConfigChecker.checkAndGet(repoAuthName, compilerName, packerName);
-            appConfig.update(appConfigUpdateDto, buildConfig);
-            appConfigRepository.save(appConfig);
-
-            AppBuilding appBuilding1 = buildingRepository.findAllByAppConfig_AppId(appId);
-            appBuilding1.setAppConfig(appConfig);
-            buildingRepository.save(appBuilding1);
-        } catch (Exception e) {
-            return Result.result(ResultStatus.FAIL, e.getMessage());
-        }
-
+        int repoAuthId = appConfigUpdateDto.getRepoAuthConfigId();
+        int compilerId = appConfigUpdateDto.getCompilerConfigId();
+        int packerId = appConfigUpdateDto.getPackerConfigId();
+        BuildConfig buildConfig = buildConfigChecker.checkAndGet(repoAuthId, compilerId, packerId);
+        appConfig.update(appConfigUpdateDto, buildConfig);
+        appBuildRepository.update(appConfig);
         return Result.result(ResultStatus.SUCCESS);
     }
 
@@ -176,9 +148,7 @@ public class AppBuildServiceImpl implements AppBuildService {
             return result;
         }
 
-        buildLogRepository.deleteByAppConfig_AppId(appId);
-        buildingRepository.deleteByAppConfig_AppId(appId);
-        appConfigRepository.deleteByAppId(appId);
+        appBuildRepository.deleteAppBuild(appId);
         clearLocalRepo(appId);
         return Result.result(ResultStatus.SUCCESS);
     }

+ 4 - 0
mgr/src/main/java/cn/reghao/devops/mgr/ops/build/model/constant/EnvType.java

@@ -16,4 +16,8 @@ public enum EnvType {
     public String getDesc() {
         return desc;
     }
+
+    public String getValue() {
+        return this.name();
+    }
 }

+ 16 - 7
mgr/src/main/java/cn/reghao/devops/mgr/ops/build/service/BuildConfigChecker.java

@@ -29,20 +29,29 @@ public class BuildConfigChecker {
         this.packerConfigRepository = packerConfigRepository;
     }
 
-    public BuildConfig checkAndGet(String repoAuthName, String compilerName, String packerName) throws Exception {
-        RepoAuthConfig repoAuthConfig = repoAuthConfigRepository.findByName(repoAuthName);
+    public RepoAuthConfig getRepoAuthConfig(int repoAuthId) {
+        RepoAuthConfig repoAuthConfig = repoAuthConfigRepository.findById(repoAuthId).orElse(null);
         if (repoAuthConfig == null) {
-            throw new Exception("仓库配置 " + repoAuthName + " 不存在");
+            throw new RuntimeException("仓库配置不存在");
         }
 
-        CompilerConfig compilerConfig = compilerConfigRepository.findByName(compilerName);
+        return repoAuthConfig;
+    }
+
+    public BuildConfig checkAndGet(int repoAuthId, int compilerId, int packerId) {
+        RepoAuthConfig repoAuthConfig = repoAuthConfigRepository.findById(repoAuthId).orElse(null);
+        if (repoAuthConfig == null) {
+            throw new RuntimeException("仓库配置不存在");
+        }
+
+        CompilerConfig compilerConfig = compilerConfigRepository.findById(compilerId).orElse(null);
         if (compilerConfig == null) {
-            throw new Exception("编译器配置 " + compilerName + " 不存在");
+            throw new RuntimeException("编译器配置不存在");
         }
 
-        PackerConfig packerConfig = packerConfigRepository.findByName(packerName);
+        PackerConfig packerConfig = packerConfigRepository.findById(packerId).orElse(null);
         if (packerConfig == null) {
-            throw new Exception("打包配置 " + packerName + " 不存在");
+            throw new RuntimeException("打包配置不存在");
         }
 
         return new BuildConfig(repoAuthConfig, compilerConfig, packerConfig);

+ 4 - 4
mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/controller/BuildDeployController.java

@@ -61,16 +61,16 @@ public class BuildDeployController {
     public String index(@RequestParam(value = "pn") int pageNumber,
                         @RequestParam(value = "env") String env,
                         @RequestParam(value = "appType") String appType,
-                        @RequestParam(value = "appName") String appName) {
+                        @RequestParam(value = "appId") String appId) {
         PageRequest pageRequest;
         Page<AppBuildingVO> page;
-        if (!appName.isBlank()) {
+        if (!appId.isBlank()) {
             Map<String, String> map = new HashMap<>();
             map.put("env", env);
             map.put("appType", appType);
-            map.put("appName", appName);
+            map.put("appId", appId);
             pageRequest = PageRequest.of(pageNumber-1, pageSize);
-            page = appBuildQuery.queryByAppName(map, pageRequest);
+            page = appBuildQuery.queryByAppId(map, pageRequest);
         } else {
             Sort sort = Sort.by(Sort.Direction.DESC, "buildTime");
             pageRequest = PageRequest.of(pageNumber-1, pageSize, sort);

+ 2 - 2
mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/db/repository/AppDeployingRepository.java

@@ -21,14 +21,14 @@ public interface AppDeployingRepository extends JpaRepository<AppDeploying, Inte
 
     @Query(value = """
         SELECT new cn.reghao.devops.mgr.ops.app.model.vo.AppNodeCount(
-            c.appId, c.appName, COUNT(n)
+            c.appId, COUNT(n)
         )
         FROM AppDeploying n
         JOIN n.appDeployConfig dc
         JOIN dc.appConfig c
         WHERE c.appType = :appType
         AND c.env = :env
-        GROUP BY c.appId, c.appName
+        GROUP BY c.appId
         """,
             countQuery = "SELECT COUNT(DISTINCT dc.appConfig.appId) FROM AppDeploying n JOIN n.appDeployConfig dc WHERE dc.appConfig.appType = :appType AND dc.appConfig.env = :env"
     )

+ 2 - 4
mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/model/vo/AppBuildingVO.java

@@ -18,11 +18,10 @@ import java.util.List;
 @Data
 public class AppBuildingVO {
     private String appId;
-    private String appName;
     private String appType;
     private String env;
     private String repoBranch;
-    private String bindPorts;
+    private int httpPort;
 
     private String buildLogId;
     private String commitId;
@@ -38,11 +37,10 @@ public class AppBuildingVO {
     public AppBuildingVO(AppBuilding appBuilding, int totalNode, int totalRunning) {
         AppConfig appConfig = appBuilding.getAppConfig();
         this.appId = appConfig.getAppId();
-        this.appName = appConfig.getAppName();
         this.appType = appConfig.getAppType();
         this.env = appConfig.getEnv();
         this.repoBranch = appConfig.getRepoBranch();
-        this.bindPorts = appConfig.getBindPorts();
+        this.httpPort = appConfig.getHttpPort();
 
         this.buildLogId = appBuilding.getBuildLog() == null ? null : appBuilding.getBuildLog().getBuildLogId();
         this.commitId = appBuilding.getCommitId();

+ 1 - 2
mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/model/vo/AppRunning.java

@@ -11,8 +11,7 @@ import lombok.Getter;
 @Getter
 public class AppRunning {
     private String appId;
-    private String appName;
-    private String bindPorts;
+    private int httpPort;
     private String packagePath;
     private int totalDeployed;
     private int totalRunning;

+ 2 - 4
mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/model/vo/AppRunningNode.java

@@ -16,10 +16,9 @@ import lombok.Data;
 @Data
 public class AppRunningNode {
     private String appId;
-    private String appName;
     private String machineId;
     private String machineIpv4;
-    private String bindPorts;
+    private int httpPort;
     private String healthCheck;
     private String packagePath;
     private String status;
@@ -31,10 +30,9 @@ public class AppRunningNode {
         AppConfig appConfig = appDeploying.getAppDeployConfig().getAppConfig();
         MachineInfo machineInfo = appDeploying.getAppDeployConfig().getMachineInfo();
         this.appId = appConfig.getAppId();
-        this.appName = appConfig.getAppName();
         this.machineId = machineInfo.getMachineId();
         this.machineIpv4 = machineInfo.getMachineIpv4();
-        this.bindPorts = appConfig.getBindPorts();
+        this.httpPort = appConfig.getHttpPort();
         this.healthCheck = appConfig.getHealthCheck();
 
         if (buildLog != null) {

+ 1 - 6
mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/service/impl/DeployAppImpl.java

@@ -93,12 +93,7 @@ public class DeployAppImpl implements DeployApp {
             return;
         }
 
-        int appPort = 0;
-        String[] bindPorts = appDeployConfig.getAppConfig().getBindPorts().split(",");
-        if (bindPorts.length > 0) {
-            appPort = Integer.parseInt(bindPorts[0]);
-        }
-
+        int appPort = appDeployConfig.getAppConfig().getHttpPort();
         EvtAppDeploy deployParam = new EvtAppDeploy();
         deployParam.setAppId(appId);
         deployParam.setAppPort(appPort);

+ 3 - 3
mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/tool/repo/CodeUpdater.java

@@ -19,7 +19,7 @@ public interface CodeUpdater {
      * @return 当前代码仓库的版本
      * @date 2019-10-12 下午11:08
      */
-    CommitInfo pull(String remote, String branch, String local) throws Exception;
+    //CommitInfo pull(String remote, String branch, String local) throws Exception;
 
     /**
      * // TODO 拉取指定版本的代码
@@ -28,7 +28,7 @@ public interface CodeUpdater {
      * @return
      * @date 2020-09-08 下午6:18
      */
-    CommitInfo update(String remote, String branch, String local, String commitId) throws Exception;
+    //CommitInfo update(String remote, String branch, String local, String commitId) throws Exception;
 
     /**
      * 本地代码仓库最近一次提交的信息
@@ -37,7 +37,7 @@ public interface CodeUpdater {
      * @param local 本地代码仓库路径
      * @date 2019-10-30 下午5:23
      */
-    CommitInfo latestCommitInfo(String local, String branch) throws Exception;
+    //CommitInfo latestCommitInfo(String local, String branch) throws Exception;
 
     CommitInfo update(PipelineContext ctx, RepoAuthConfig repoAuthConfig) throws Exception;
     String supportType();

+ 84 - 90
mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/tool/repo/GitImpl.java → mgr/src/main/java/cn/reghao/devops/mgr/ops/builder/tool/repo/GitClient.java

@@ -20,10 +20,7 @@ import org.eclipse.jgit.treewalk.CanonicalTreeParser;
 import org.springframework.stereotype.Component;
 
 import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
 
 /**
  * Git 实现
@@ -32,18 +29,7 @@ import java.util.List;
  * @date 2019-10-12 22:22:00
  */
 @Component
-public class GitImpl implements CodeUpdater {
-    private UsernamePasswordCredentialsProvider credentials;
-    private SshSessionFactory sshSessionFactory;
-
-    private void httpAuth(String username, String password) {
-        this.credentials = new UsernamePasswordCredentialsProvider(username, password);
-    }
-
-    private void sshAuth(String privateKey) {
-        this.sshSessionFactory = new CustomSshSessionFactory(privateKey);
-    }
-
+public class GitClient implements CodeUpdater {
     /**
      * 不存在则 clone,存在则 pull
      *
@@ -51,8 +37,7 @@ public class GitImpl implements CodeUpdater {
      * @return
      * @date 2020-05-13 下午9:22
      */
-    @Override
-    public CommitInfo pull(String remote, String branch, String local) throws Exception {
+    public CommitInfo pull(String remote, String branch, String local, RepoAuthConfig repoAuthConfig) throws Exception {
         File file = new File(local);
         if (!file.exists() && !file.mkdirs()) {
             throw new Exception("创建 " + local + " 目录失败");
@@ -61,28 +46,29 @@ public class GitImpl implements CodeUpdater {
         File localRepo = new File(local + "/.git");
         CommitInfo commitInfo;
         if (!localRepo.exists()) {
-            commitInfo = clone(remote, branch, local);
+            commitInfo = clone(remote, branch, local, repoAuthConfig);
         } else {
             try (Repository repo = new FileRepository(localRepo.getAbsolutePath())) {
-                PullCommand gitPull = new Git(repo)
+                PullCommand pullCommand = new Git(repo)
                         .pull()
                         // 超时 60s
                         .setTimeout(60)
                         .setFastForward(MergeCommand.FastForwardMode.FF);
-                if (sshSessionFactory != null) {
-                    gitPull.setTransportConfigCallback(transport -> {
+
+                Map<String, Object> map = getRepoAuth(repoAuthConfig);
+                if (map.get(RepoAuthType.http.name()) != null) {
+                    UsernamePasswordCredentialsProvider credentials = (UsernamePasswordCredentialsProvider) map.get(RepoAuthType.http.name());
+                    pullCommand.setCredentialsProvider(credentials);
+                } else if (map.get(RepoAuthType.ssh.name()) != null) {
+                    SshSessionFactory sshSessionFactory = (SshSessionFactory) map.get(RepoAuthType.ssh.name());
+                    pullCommand.setTransportConfigCallback(transport -> {
                         if (transport instanceof SshTransport) {
-                            setSshTransport((SshTransport) transport);
+                            setSshTransport((SshTransport) transport, sshSessionFactory);
                         }
                     });
-                    gitPull.call();
-                } else if (credentials != null) {
-                    gitPull.setCredentialsProvider(credentials);
-                    gitPull.call();
-                } else {
-                    gitPull.call();
                 }
 
+                pullCommand.call();
                 commitInfo = commitInfo(repo, branch);
                 commitInfo.setChangedFiles(changedFileList(repo, branch));
             }
@@ -92,33 +78,27 @@ public class GitImpl implements CodeUpdater {
         return commitInfo;
     }
 
-    private CommitInfo clone(String remote, String branch, String local) throws Exception {
-        CloneCommand gitClone;
-        if (sshSessionFactory != null) {
-            gitClone = Git.cloneRepository()
-                    .setTimeout(600)
-                    .setURI(remote)
-                    .setBranch(branch)
-                    .setDirectory(new File(local))
-                    .setTransportConfigCallback(transport -> {
-                        if (transport instanceof SshTransport) {
-                            setSshTransport((SshTransport) transport);
-                        }
-                    });
-        } else if (credentials != null) {
-            gitClone = Git.cloneRepository()
-                    .setURI(remote)
-                    .setBranch(branch)
-                    .setDirectory(new File(local))
-                    .setCredentialsProvider(credentials);
-        } else {
-            gitClone = Git.cloneRepository()
-                    .setURI(remote)
-                    .setBranch(branch)
-                    .setDirectory(new File(local));
+    private CommitInfo clone(String remote, String branch, String local, RepoAuthConfig repoAuthConfig) throws Exception {
+        CloneCommand cloneCommand = Git.cloneRepository()
+                .setURI(remote)
+                .setBranch(branch)
+                .setTimeout(600)
+                .setDirectory(new File(local));
+
+        Map<String, Object> map = getRepoAuth(repoAuthConfig);
+        if (map.get(RepoAuthType.http.name()) != null) {
+            UsernamePasswordCredentialsProvider credentials = (UsernamePasswordCredentialsProvider) map.get(RepoAuthType.http.name());
+            cloneCommand.setCredentialsProvider(credentials);
+        } else if (map.get(RepoAuthType.ssh.name()) != null) {
+            SshSessionFactory sshSessionFactory = (SshSessionFactory) map.get(RepoAuthType.ssh.name());
+            cloneCommand.setTransportConfigCallback(transport -> {
+                if (transport instanceof SshTransport) {
+                    setSshTransport((SshTransport) transport, sshSessionFactory);
+                }
+            });
         }
 
-        try (Git git = gitClone.setDepth(1).call()) {
+        try (Git git = cloneCommand.setDepth(1).call()) {
             Repository repo = git.getRepository();
             CommitInfo commitInfo = commitInfo(repo, branch);
             commitInfo.setChangedFiles(changedFileList(repo, branch));
@@ -126,7 +106,7 @@ public class GitImpl implements CodeUpdater {
         }
     }
 
-    private void setSshTransport(SshTransport sshTransport) {
+    private void setSshTransport(SshTransport sshTransport, SshSessionFactory sshSessionFactory) {
         // Set passphrase using a CustomCredentialsProvider
         sshTransport.setCredentialsProvider(new CustomCredentialProvider(null));
         sshTransport.setSshSessionFactory(sshSessionFactory);
@@ -204,13 +184,6 @@ public class GitImpl implements CodeUpdater {
         }
     }
 
-    @Override
-    public CommitInfo update(String remote, String branch, String local, String commitId) throws Exception {
-        // TODO 待实现
-        return null;
-    }
-
-    @Override
     public CommitInfo latestCommitInfo(String local, String branch) throws Exception {
         File localRepo = new File(local + "/.git");
         if (!localRepo.exists()) {
@@ -222,26 +195,6 @@ public class GitImpl implements CodeUpdater {
         }
     }
 
-    public List<String> remoteBranches(String remote) {
-        List<String> branches = new ArrayList<>();
-        try {
-            Collection<Ref> refList = Git.lsRemoteRepository().setRemote(remote)
-                    .setCredentialsProvider(credentials).call();
-            for (Ref ref : refList) {
-                String refName = ref.getName();
-                if (refName.startsWith("refs/heads/")) {
-                    // 需要进行筛选
-                    String branchName = refName.replace("refs/heads/", "");
-                    branches.add(branchName);
-                }
-            }
-            return branches;
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return branches;
-    }
-
     /**
      * 提交代码并 push 到远程仓库
      *
@@ -278,27 +231,68 @@ public class GitImpl implements CodeUpdater {
         // git commit -m "commit message"
         RevCommit revCommit = commitCommand.setMessage(commitMsg).call();
         PushCommand pushCommand = git.push();
-        pushCommand.setRemote(pushUrl).setCredentialsProvider(credentials).call();
+        //pushCommand.setRemote(pushUrl).setCredentialsProvider(credentials).call();
     }
 
-    @Override
-    public CommitInfo update(PipelineContext ctx, RepoAuthConfig repoAuthConfig) throws Exception {
+    public boolean checkRemoteBranch(String repoUrl, String branch, RepoAuthConfig repoAuthConfig) {
+        try {
+            LsRemoteCommand lsRemoteCommand = Git.lsRemoteRepository()
+                    .setRemote(repoUrl)
+                    .setHeads(true) // 只看分支,不看 Tags
+                    .setTags(false);
+
+            // 如果是私有仓库,需要设置凭据
+            Map<String, Object> map = getRepoAuth(repoAuthConfig);
+            if (map.get(RepoAuthType.http.name()) != null) {
+                UsernamePasswordCredentialsProvider credentials = (UsernamePasswordCredentialsProvider) map.get(RepoAuthType.http.name());
+                lsRemoteCommand.setCredentialsProvider(credentials);
+            } else if (map.get(RepoAuthType.ssh.name()) != null) {
+                SshSessionFactory sshSessionFactory = (SshSessionFactory) map.get(RepoAuthType.ssh.name());
+                lsRemoteCommand.setTransportConfigCallback(transport -> {
+                    if (transport instanceof SshTransport) {
+                        setSshTransport((SshTransport) transport, sshSessionFactory);
+                    }
+                });
+            }
+
+
+            // 获取远程所有引用
+            Collection<Ref> refs = lsRemoteCommand.call();
+            // 检查是否存在匹配的分支名
+            // 远程分支在 refs 中通常以 refs/heads/branchName 形式存在
+            String fullBranchName = "refs/heads/" + branch;
+            return refs.stream().anyMatch(ref -> ref.getName().equals(fullBranchName));
+        } catch (Exception e) {
+            // 如果仓库不存在或鉴权失败,会抛出异常
+            System.err.println("仓库连接失败或不存在: " + e.getMessage());
+            return false;
+        }
+    }
+
+    private Map<String, Object> getRepoAuth(RepoAuthConfig repoAuthConfig) {
+        Map<String, Object> map = new HashMap<>();
         switch (RepoAuthType.valueOf(repoAuthConfig.getAuthType())) {
             case http:
-                httpAuth(repoAuthConfig.getUsername(), repoAuthConfig.getPassword());
+                UsernamePasswordCredentialsProvider credentials0 =
+                        new UsernamePasswordCredentialsProvider(repoAuthConfig.getUsername(), repoAuthConfig.getPassword());
+                map.put(RepoAuthType.http.name(), credentials0);
                 break;
             case ssh:
-                sshAuth(repoAuthConfig.getRsaPrikey());
+                SshSessionFactory sshSessionFactory0 = new CustomSshSessionFactory(repoAuthConfig.getRsaPrikey());
+                map.put(RepoAuthType.ssh.name(), sshSessionFactory0);
                 break;
-            default:
-                return null;
         }
 
+        return map;
+    }
+
+    @Override
+    public CommitInfo update(PipelineContext ctx, RepoAuthConfig repoAuthConfig) throws Exception {
         String remote = ctx.getGitUrl();
         String branch = ctx.getBranch();
         String local = ctx.getGitLocal();
         CommitInfo last = latestCommitInfo(local, branch);
-        CommitInfo current = pull(remote, branch, local);
+        CommitInfo current = pull(remote, branch, local, repoAuthConfig);
         if (last == null || last.getMsCommitTime() <= current.getMsCommitTime()) {
             // 本地仓库不存在 or 本地仓库版本和远程仓库相同 or 本地仓库版本落后于远程仓库
             BuilderUtil.copyToCompileDir(ctx);

+ 1 - 2
mgr/src/main/java/cn/reghao/devops/mgr/ops/machine/service/impl/MachineQueryImpl.java

@@ -90,8 +90,7 @@ public class MachineQueryImpl implements MachineQuery {
         return deployConfigRepository.findByMachineInfo(machineInfo).stream()
                 .map(appDeployConfig -> {
                     String appId = appDeployConfig.getAppConfig().getAppId();
-                    String appName = appDeployConfig.getAppConfig().getAppName();
-                    return new SelectOption(appId, appName);
+                    return new SelectOption(appId, appId);
                 })
                 .collect(Collectors.toList());
     }

+ 0 - 19
mgr/src/test/java/devops/GitTest.java

@@ -1,8 +1,5 @@
 package devops;
 
-import cn.reghao.devops.mgr.ops.build.model.po.RepoAuthConfig;
-import cn.reghao.devops.mgr.ops.build.model.constant.RepoAuthType;
-import cn.reghao.devops.mgr.ops.builder.tool.repo.GitImpl;
 import cn.reghao.devops.mgr.ops.deployer.model.constant.SshAuthType;
 import cn.reghao.devops.mgr.ops.deployer.model.po.RemoteHost;
 import cn.reghao.devops.mgr.ops.deployer.util.Sftp;
@@ -27,22 +24,6 @@ import java.util.List;
  * @date 2022-05-07 09:32:40
  */
 public class GitTest {
-    @Test
-    public void gitTest() throws Exception {
-        String repo = "";
-        String username = "";
-        String password = "";
-
-        RepoAuthConfig repoAuthConfig = new RepoAuthConfig();
-        repoAuthConfig.setAuthType(RepoAuthType.http.getName());
-        repoAuthConfig.setUsername(username);
-        repoAuthConfig.setPassword(password);
-
-        GitImpl git = new GitImpl();
-        List<String> list = git.remoteBranches(repo);
-        System.out.println();
-    }
-
     @Test
     public void repoTest() throws IOException, GitAPIException {
         String localRepo = "/home/reghao/code/java/jutil/.git";