创建应用中的git-ci


#1
  • Choerodon平台版本:0.16.0

创建应用 之后,我看是调用到devops项目的接口,然后在接口里没看懂逻辑。想问一下,之后后gitlab-ci是怎么做的,最好能具体到代码。


#2

你好,可以本地运行debug 下逻辑。

代码可以从github 获取。


#3

@Override
@Saga(code = “devops-create-application”,
description = “Devops创建应用”, inputSchema = “{}”)
public ApplicationRepDTO create(Long projectId, ApplicationReqDTO applicationReqDTO) {
UserAttrE userAttrE = userAttrRepository.queryById(TypeUtil.objToLong(GitUserNameUtil.getUserId()));
ApplicationValidator.checkApplication(applicationReqDTO);
ProjectE projectE = iamRepository.queryIamProject(projectId);
Organization organization = iamRepository.queryOrganizationById(projectE.getOrganization().getId());
// 查询创建应用所在的gitlab应用组
DevopsProjectE devopsProjectE = devopsProjectRepository.queryDevopsProject(projectId);
GitlabMemberE gitlabMemberE = gitlabGroupMemberRepository.getUserMemberByUserId(
TypeUtil.objToInteger(devopsProjectE.getDevopsAppGroupId()),
TypeUtil.objToInteger(userAttrE.getGitlabUserId()));
if (gitlabMemberE == null || gitlabMemberE.getAccessLevel() != AccessLevel.OWNER.toValue()) {
throw new CommonException(“error.user.not.owner”);
}

ApplicationE applicationE = getApplicationE(projectId, applicationReqDTO);
applicationE = applicationRepository.create(applicationE);

Long appId = applicationE.getId();
if (appId == null) {
throw new CommonException(“error.application.create.insert”);
}
// 如果不跳过权限检查
List<Long> userIds = applicationReqDTO.getUserIds();
if (!applicationReqDTO.getIsSkipCheckPermission() && userIds != null && !userIds.isEmpty()) {
userIds.forEach(e -> appUserPermissionRepository.create(e, appId));
}

IamAppPayLoad iamAppPayLoad = new IamAppPayLoad();
iamAppPayLoad.setApplicationCategory(APPLICATION);
iamAppPayLoad.setApplicationType(applicationReqDTO.getType());
iamAppPayLoad.setCode(applicationReqDTO.getCode());
iamAppPayLoad.setName(applicationReqDTO.getName());
iamAppPayLoad.setEnabled(true);
iamAppPayLoad.setOrganizationId(organization.getId());
iamAppPayLoad.setProjectId(projectId);
iamAppPayLoad.setFrom(applicationName);

iamRepository.createIamApp(organization.getId(), iamAppPayLoad);
return ConvertHelper.convert(applicationRepository.queryByCode(applicationE.getCode(),
applicationE.getProjectE().getId()), ApplicationRepDTO.class);
}

不知道是哪个方法调的,而且是以什么形式调用的。


现有项目集成到C7N,疑问
#4

gitlab-ci是基于gitlab组件的gitlab-ci进行ci流程的,通过代码路径中的gitlab-ci.yml进行定义,详细的文档和过程可以参考gitlab-ci的相关文档:
https://docs.gitlab.com/ee/ci/README.html
如果只是正常使用,直接参考模板文件中的gitlab-ci.yaml文件的编写即可


#5

好的,感谢。