Merge branch 'dev_PMS' of code.gitlink.org.cn:Gitlink/microservices into dev_PMS_ZPK

This commit is contained in:
OTTO 2024-08-22 11:28:43 +08:00
commit 55d9d3f6ac
6 changed files with 44 additions and 13 deletions

View File

@ -18,6 +18,7 @@ import com.microservices.pms.enums.ProjectIssueStatus;
import com.microservices.pms.product.domain.PmsProductRequirement; import com.microservices.pms.product.domain.PmsProductRequirement;
import com.microservices.pms.product.service.IPmsProductRequirementService; import com.microservices.pms.product.service.IPmsProductRequirementService;
import com.microservices.pms.project.domain.*; import com.microservices.pms.project.domain.*;
import com.microservices.pms.project.domain.vo.PmsProjectInputVo;
import com.microservices.pms.project.domain.vo.PmsProjectIssuesInputVo; import com.microservices.pms.project.domain.vo.PmsProjectIssuesInputVo;
import com.microservices.pms.project.domain.vo.PmsProjectTestReportInputVo; import com.microservices.pms.project.domain.vo.PmsProjectTestReportInputVo;
import com.microservices.pms.project.domain.vo.PmsProjectTestsheetCaseInputVo; import com.microservices.pms.project.domain.vo.PmsProjectTestsheetCaseInputVo;
@ -78,6 +79,9 @@ public class PmsCommonAsyncServiceImpl implements IPmsCommonAsyncService {
@Autowired @Autowired
@Lazy @Lazy
private IPmsProductRequirementService pmsProductRequirementService; private IPmsProductRequirementService pmsProductRequirementService;
@Autowired
@Lazy
private IPmsProjectService pmsProjectService;
private static final String INITIALIZE_NAME = "【示例%s】研发示例%s"; private static final String INITIALIZE_NAME = "【示例%s】研发示例%s";
@ -398,14 +402,12 @@ public class PmsCommonAsyncServiceImpl implements IPmsCommonAsyncService {
} }
private Long initializePmsProject(Long id, Long creatorGitLinkUserId) { private Long initializePmsProject(Long id, Long creatorGitLinkUserId) {
PmsEnterprise pmsEnterprise = pmsEnterpriseService.selectPmsEnterpriseById(id); // 创建项目
PmsProject pmsProject = new PmsProject(); PmsProjectInputVo pmsProjectInputVo = new PmsProjectInputVo();
pmsProject.setPmsEnterpriseId(id); pmsProjectInputVo.setPmsEnterpriseId(id);
String name = "项目"; String name = "项目";
pmsProject.setProjectName(String.format(INITIALIZE_NAME, name, name)); pmsProjectInputVo.setProjectName(String.format(INITIALIZE_NAME, name, name));
pmsProject.setProjectAssigneeId(creatorGitLinkUserId); pmsProjectInputVo.setProjectAssigneeId(creatorGitLinkUserId);
pmsProject.setDeptId(pmsEnterprise.getDeptId()); return (long) pmsProjectService.insertPmsProject(pmsProjectInputVo);
pmsProjectMapper.insertPmsProject(pmsProject);
return pmsProject.getId();
} }
} }

View File

@ -204,6 +204,18 @@ public class PmsCiPipelinesController extends BaseController
return success(pmsCiPipelinesService.savePipelineYamlByGraphicJson(id, pmsCiPipelineBuildInputVo)); return success(pmsCiPipelinesService.savePipelineYamlByGraphicJson(id, pmsCiPipelineBuildInputVo));
} }
/**
* 启动流水线执行记录任务
*/
@PostMapping(value = "/{id}/actions/runs/run")
@ApiOperation("启动流水线执行记录任务")
public AjaxResult runPipelineRunsJob(@ApiParam(name = "id", value = "流水线id") @PathVariable Long id,
@ApiParam(name = "workflow", value = "流水线文件名称", required = true) @RequestParam String workflow,
@ApiParam(name = "ref", value = "分支名称", required = true) @RequestParam String ref)
{
return success(pmsCiPipelinesService.runPipelineRunsJob(id, workflow, ref));
}
/** /**
* 重启流水线执行记录任务 * 重启流水线执行记录任务
*/ */

View File

@ -96,4 +96,6 @@ public interface IPmsCiPipelinesService
JSONObject reRunAllJobsInPipelineRun(Long id, String run); JSONObject reRunAllJobsInPipelineRun(Long id, String run);
void getPipelineRunJobLogs(Long id, String run, String job, HttpServletResponse response); void getPipelineRunJobLogs(Long id, String run, String job, HttpServletResponse response);
JSONObject runPipelineRunsJob(Long id, String workflow, String ref);
} }

View File

@ -123,7 +123,6 @@ public class PmsCiPipelinesServiceImpl implements IPmsCiPipelinesService {
checkPipelineExistence(pmsCiPipelinesInputVo); checkPipelineExistence(pmsCiPipelinesInputVo);
PmsCiPipelines pmsCiPipelines = buildPmsCiPipelines(pmsCiPipelinesInputVo, enterpriseIdentifier); PmsCiPipelines pmsCiPipelines = buildPmsCiPipelines(pmsCiPipelinesInputVo, enterpriseIdentifier);
pmsCiPipelinesMapper.insertPmsCiPipelines(pmsCiPipelines); pmsCiPipelinesMapper.insertPmsCiPipelines(pmsCiPipelines);
openRepoActionModule(pmsCiPipelines.getOwner(), pmsCiPipelines.getRepoIdentifier());
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("id", pmsCiPipelines.getId()); result.put("id", pmsCiPipelines.getId());
return result; return result;
@ -376,6 +375,18 @@ public class PmsCiPipelinesServiceImpl implements IPmsCiPipelinesService {
job), null); job), null);
} }
@Override
public JSONObject runPipelineRunsJob(Long id, String workflow, String ref) {
PmsCiPipelines pmsCiPipelines = pmsCiPipelinesMapper.selectPmsCiPipelinesById(id);
if (pmsCiPipelines == null) {
throw new ServiceException("该项目流水线不存在(流水线ID[%s])", id);
}
return gitLinkRequestHelper.doPost(PmsGitLinkRequestUrl.RUN_PIPELINE_RUNS_JOB(pmsCiPipelines.getOwner(),
pmsCiPipelines.getRepoIdentifier(),
workflow,
ref), null);
}
@Override @Override
public JSONObject reRunAllJobsInPipelineRun(Long id, String run) { public JSONObject reRunAllJobsInPipelineRun(Long id, String run) {
PmsCiPipelines pmsCiPipelines = pmsCiPipelinesMapper.selectPmsCiPipelinesById(id); PmsCiPipelines pmsCiPipelines = pmsCiPipelinesMapper.selectPmsCiPipelinesById(id);

View File

@ -183,7 +183,7 @@ public class PmsProjectServiceImpl implements IPmsProjectService
} }
PmsProject pmsProject = pmsProjectInputVo.toPmsProject(); PmsProject pmsProject = pmsProjectInputVo.toPmsProject();
pmsProject.setDeptId(pmsEnterprise.getDeptId()); pmsProject.setDeptId(pmsEnterprise.getDeptId());
int count = pmsProjectMapper.insertPmsProject(pmsProject); pmsProjectMapper.insertPmsProject(pmsProject);
//同步新增项目-仓库数据 //同步新增项目-仓库数据
if (StringUtils.isNotEmpty(pmsProjectInputVo.getProjectRepositoryIds())) { if (StringUtils.isNotEmpty(pmsProjectInputVo.getProjectRepositoryIds())) {
List<String> repositoryIdList = Arrays.asList(pmsProjectInputVo.getProjectRepositoryIds().split(",")); List<String> repositoryIdList = Arrays.asList(pmsProjectInputVo.getProjectRepositoryIds().split(","));
@ -220,7 +220,7 @@ public class PmsProjectServiceImpl implements IPmsProjectService
} }
} }
} }
return count; return pmsProject.getId().intValue();
} }
/** /**

View File

@ -368,6 +368,10 @@ public class PmsGitLinkRequestUrl extends GitLinkRequestUrl {
return getGitLinkRequestUrl(String.format("/api/v1/%s/%s/actions/runs/%s/jobs/%s/rerun", owner, repoIdentifier, run, job)); return getGitLinkRequestUrl(String.format("/api/v1/%s/%s/actions/runs/%s/jobs/%s/rerun", owner, repoIdentifier, run, job));
} }
public static GitLinkRequestUrl RUN_PIPELINE_RUNS_JOB(String owner, String repoIdentifier, String workflow, String ref){
return getGitLinkRequestUrl(String.format("/api/v1/%s/%s/actions/runs?workflow=%s&ref=%s", owner, repoIdentifier, workflow, ref));
}
public static GitLinkRequestUrl RERUN_ALL_JOBS_IN_PIPELINE_RUN(String owner, String repoIdentifier, String run){ public static GitLinkRequestUrl RERUN_ALL_JOBS_IN_PIPELINE_RUN(String owner, String repoIdentifier, String run){
return getGitLinkRequestUrl(String.format("/api/v1/%s/%s/actions/runs/%s/rerun", owner, repoIdentifier, run)); return getGitLinkRequestUrl(String.format("/api/v1/%s/%s/actions/runs/%s/rerun", owner, repoIdentifier, run));
} }