Search in sources :

Example 6 with ProjectModule

use of com.ibeiliao.deployment.admin.vo.project.ProjectModule in project Corgi by kevinYin.

the class CreateDeploymentController method listRepository.

@RequestMapping("listRepository")
@MenuResource("查询分支列表")
@ResponseBody
public RestResult<List<Map<String, Object>>> listRepository(int moduleId) {
    ProjectModule module = projectModuleService.getByModuleId(moduleId);
    List<Map<String, Object>> tags = new ArrayList<>();
    if (module != null) {
        if (module.getRepoType() == ModuleRepoType.SVN.getValue()) {
            String tagsPath = (module.getRepoUrl() + RepositoryConstants.TAGS).replaceAll("/" + RepositoryConstants.TAGS, RepositoryConstants.TAGS);
            tags.addAll(fetchSvnTags(tagsPath, module));
            String branchesPath = (module.getRepoUrl() + RepositoryConstants.BRANCHES).replaceAll("/" + RepositoryConstants.BRANCHES, RepositoryConstants.BRANCHES);
            tags.addAll(fetchSvnTags(branchesPath, module));
        } else if (module.getRepoType() == ModuleRepoType.GIT.getValue()) {
            tags.addAll(fetchGitBranches(module.getRepoUrl(), module));
        } else {
            logger.warn("不支持类型 {}, moduleId: {}", module.getRepoType(), moduleId);
        }
    } else {
        logger.error("module=null, moduleId: " + moduleId);
    }
    return new RestResult<>(tags);
}
Also used : ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) RestResult(com.ibeiliao.deployment.admin.common.RestResult) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with ProjectModule

use of com.ibeiliao.deployment.admin.vo.project.ProjectModule in project Corgi by kevinYin.

the class ProjectServiceImpl method fillModuleInfo.

private void fillModuleInfo(List<Project> projects) {
    List<Integer> projectIds = Lists.newArrayList();
    for (Project project : projects) {
        projectIds.add(project.getProjectId());
    }
    List<ProjectModule> projectModules = projectModuleService.getSimpleInfoByProjectIds(projectIds);
    if (CollectionUtils.isEmpty(projectModules)) {
        return;
    }
    ListMultimap<Integer, ProjectModule> projectId2ModulesMap = ArrayListMultimap.create();
    for (ProjectModule module : projectModules) {
        projectId2ModulesMap.put(module.getProjectId(), module);
    }
    for (Project project : projects) {
        project.setProjectModules(projectId2ModulesMap.get(project.getProjectId()));
    }
}
Also used : Project(com.ibeiliao.deployment.admin.vo.project.Project) ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule)

Example 8 with ProjectModule

use of com.ibeiliao.deployment.admin.vo.project.ProjectModule in project Corgi by kevinYin.

the class DeployHistoryServiceImpl method checkIfDeployingModuleWithEnv.

private void checkIfDeployingModuleWithEnv(DeploymentOrder order) {
    // 如果 module 正在 env 发布,不能再创建发布
    if (moduleStatusManagementService.isModuleDeploying(order.getModuleId(), order.getEnvId())) {
        ProjectModule module = projectModuleService.getByModuleId(order.getModuleId());
        ProjectEnv env = projectEnvService.getById(order.getEnvId());
        throw new IllegalStateException("模块 [" + module.getModuleName() + "] 正在 [" + env.getEnvName() + "] 环境发布,必须等待当前的发布结束才可以发布");
    }
}
Also used : ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) ProjectEnv(com.ibeiliao.deployment.admin.vo.global.ProjectEnv)

Example 9 with ProjectModule

use of com.ibeiliao.deployment.admin.vo.project.ProjectModule in project Corgi by kevinYin.

the class DeployHistoryServiceImpl method createAndSaveRestart.

private DeployHistoryPO createAndSaveRestart(long accountId, String title, int serverId) {
    Server server = serverService.getById(serverId);
    AdminAccount account = adminAccountService.getById(accountId);
    Assert.notNull(server, "服务器不存在");
    Assert.notNull(account, "管理员不存在");
    ServerGroup serverGroup = serverGroupService.getById(server.getGroupId());
    ProjectModule module = projectModuleService.getByModuleId(serverGroup.getModuleId());
    DeployHistoryPO po = new DeployHistoryPO();
    po.setTagName("");
    po.setAccountId(accountId);
    po.setAuditorId(0);
    po.setTitle(title);
    po.setCreateTime(new Date());
    po.setDeployStatus(DeployStatus.WAITING_FOR_DEPLOYMENT.getValue());
    po.setAuditTime(po.getCreateTime());
    po.setDeployServers(1);
    po.setProjectId(module.getProjectId());
    po.setModuleId(module.getModuleId());
    po.setModuleName(module.getModuleName());
    po.setVersionNo("");
    po.setIsRestart(Constants.TRUE);
    po.setEnvId(serverGroup.getEnvId());
    po.setRealName(account.getRealname());
    deployHistoryDao.insert(po);
    ServerDeployHistoryPO serverDeployHistoryPO = new ServerDeployHistoryPO();
    serverDeployHistoryPO.setHistoryId(po.getHistoryId());
    serverDeployHistoryPO.setServerId(serverId);
    serverDeployHistoryPO.setServerName(server.getServerName());
    serverDeployHistoryPO.setServerIp(server.getIp());
    serverDeployHistoryPO.setDeployStatus(ServerDeployResult.WAITING_FOR_DEPLOYMENT.getValue());
    serverDeployHistoryDao.insert(serverDeployHistoryPO);
    return deployHistoryDao.get(po.getHistoryId());
}
Also used : ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) ServerGroup(com.ibeiliao.deployment.admin.vo.server.ServerGroup) Server(com.ibeiliao.deployment.admin.vo.server.Server) ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) DeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO) ServerDeployHistoryPO(com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO) AdminAccount(com.ibeiliao.deployment.admin.vo.account.AdminAccount)

Example 10 with ProjectModule

use of com.ibeiliao.deployment.admin.vo.project.ProjectModule in project Corgi by kevinYin.

the class CreateDeploymentController method index.

/**
 * 创建上线单主页,xhtml 仅用于展示页面,ajax 调用 .do 接口获取参数
 *
 * @return
 */
@MenuResource("创建上线单主页")
@RequestMapping("create.xhtml")
public String index(HttpServletRequest request) {
    // 读取用户可以访问的项目
    long accountId = AdminContext.getAccountId();
    List<Project> projects = projectService.queryAdminProjects(accountId, null, 0L, null, 1, MAX_DISPLAY_PROJECTS);
    List<ProjectModule> modules = new LinkedList<>();
    List<ProjectModule> projectModules = null;
    // 读取每个项目的module
    for (Project project : projects) {
        List<ProjectModule> tmpModules = projectModuleService.getByProjectId(project.getProjectId());
        modules.addAll(tmpModules);
    }
    request.setAttribute("projects", projects);
    request.setAttribute("allModules", JSON.toJSON(modules));
    int moduleId = 0;
    int projectId = 0;
    if (request.getParameter("moduleId") != null) {
        moduleId = NumberUtils.toInt(request.getParameter("moduleId"), 0);
        if (moduleId > 0) {
            ProjectModule module = projectModuleService.getByModuleId(moduleId);
            if (module != null) {
                projectId = module.getProjectId();
            }
        }
        logger.info("输入参数 moduleId: " + moduleId + ", projectId: " + projectId);
    }
    if (projectId <= 0 && projects.size() > 0) {
        projectId = projects.get(0).getProjectId();
        projectModules = projectModuleService.getByProjectId(projectId);
    } else if (projectId > 0) {
        projectModules = projectModuleService.getByProjectId(projectId);
    } else {
        projectModules = Collections.emptyList();
    }
    String repoUrl = "";
    if (moduleId <= 0 && projectModules.size() > 0) {
        moduleId = projectModules.get(0).getModuleId();
        repoUrl = projectModules.get(0).getRepoUrl();
    } else {
        for (ProjectModule pm : projectModules) {
            if (pm.getModuleId() == moduleId) {
                repoUrl = pm.getRepoUrl();
                break;
            }
        }
    }
    // 指定发布的module
    request.setAttribute("moduleId", moduleId);
    request.setAttribute("projectId", projectId);
    request.setAttribute("projectModules", projectModules);
    request.setAttribute("repoUrl", repoUrl);
    request.setAttribute("envList", projectEnvService.findAllEnv());
    return ("/deploy/create_deployment");
}
Also used : Project(com.ibeiliao.deployment.admin.vo.project.Project) ProjectModule(com.ibeiliao.deployment.admin.vo.project.ProjectModule) MenuResource(com.ibeiliao.deployment.admin.utils.resource.MenuResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ProjectModule (com.ibeiliao.deployment.admin.vo.project.ProjectModule)17 ProjectEnv (com.ibeiliao.deployment.admin.vo.global.ProjectEnv)3 Project (com.ibeiliao.deployment.admin.vo.project.Project)3 Server (com.ibeiliao.deployment.admin.vo.server.Server)3 ServerGroup (com.ibeiliao.deployment.admin.vo.server.ServerGroup)3 RestResult (com.ibeiliao.deployment.admin.common.RestResult)2 DeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.DeployHistoryPO)2 ServerDeployHistoryPO (com.ibeiliao.deployment.admin.po.deploy.ServerDeployHistoryPO)2 ProjectModulePO (com.ibeiliao.deployment.admin.po.project.ProjectModulePO)2 MenuResource (com.ibeiliao.deployment.admin.utils.resource.MenuResource)2 AdminAccount (com.ibeiliao.deployment.admin.vo.account.AdminAccount)2 ModuleJvm (com.ibeiliao.deployment.admin.vo.project.ModuleJvm)2 Test (org.junit.Test)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ProjectPO (com.ibeiliao.deployment.admin.po.project.ProjectPO)1 DeployHistory (com.ibeiliao.deployment.admin.vo.deploy.DeployHistory)1 Transactional (org.springframework.transaction.annotation.Transactional)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1