Skip to content

Commit

Permalink
Merge pull request #11164 from royalhuang/issue_10958_api
Browse files Browse the repository at this point in the history
feat:推荐版本号优化 #10958 增加版本管理api接口
  • Loading branch information
mingshewhe authored Nov 11, 2024
2 parents b0d4019 + ba012ac commit 1d18f27
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import com.tencent.devops.common.api.pojo.Page
import com.tencent.devops.common.api.pojo.Result
import com.tencent.devops.common.pipeline.PipelineVersionWithModel
import com.tencent.devops.common.pipeline.PipelineVersionWithModelRequest
import com.tencent.devops.common.pipeline.pojo.BuildNoUpdateReq
import com.tencent.devops.process.pojo.pipeline.DeployPipelineResult
import com.tencent.devops.common.pipeline.pojo.TemplateInstanceCreateRequest
import com.tencent.devops.common.pipeline.pojo.transfer.PreviewResponse
Expand Down Expand Up @@ -423,12 +422,12 @@ interface ApigwPipelineVersionResourceV4 {
): Response

@Operation(
summary = "重置流水线推荐版本号",
tags = ["v4_app_pipeline_update_build_no", "v4_user_pipeline_update_build_no"]
summary = "重置流水线推荐版本号(未启用推荐版本号则返回false)",
tags = ["v4_app_pipeline_reset_build_no", "v4_user_pipeline_reset_build_no"]
)
@POST
@Path("/update_build_no")
fun updateBuildNo(
@Path("/reset_build_no")
fun resetBuildNo(
@Parameter(description = "appCode", required = true, example = AUTH_HEADER_DEVOPS_APP_CODE_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_DEVOPS_APP_CODE)
appCode: String?,
Expand All @@ -443,8 +442,6 @@ interface ApigwPipelineVersionResourceV4 {
projectId: String,
@Parameter(description = "流水线ID", required = true)
@QueryParam("pipelineId")
pipelineId: String,
@Parameter(description = "流水线构建推荐版本号更新", required = true)
buildNo: BuildNoUpdateReq
pipelineId: String
): Result<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import com.tencent.devops.common.api.pojo.Result
import com.tencent.devops.common.client.Client
import com.tencent.devops.common.pipeline.PipelineVersionWithModel
import com.tencent.devops.common.pipeline.PipelineVersionWithModelRequest
import com.tencent.devops.common.pipeline.pojo.BuildNoUpdateReq
import com.tencent.devops.common.web.RestResource
import com.tencent.devops.openapi.utils.ApiGatewayUtil
import com.tencent.devops.process.pojo.pipeline.DeployPipelineResult
Expand Down Expand Up @@ -292,20 +291,18 @@ class ApigwPipelineVersionResourceV4Impl @Autowired constructor(
)
}

override fun updateBuildNo(
override fun resetBuildNo(
appCode: String?,
apigwType: String?,
userId: String,
projectId: String,
pipelineId: String,
buildNo: BuildNoUpdateReq
pipelineId: String
): Result<Boolean> {
logger.info("OPENAPI_PIPELINE_V4|$userId|updateBuildNo|$projectId|$pipelineId")
return client.get(ServicePipelineVersionResource::class).updateBuildNo(
logger.info("OPENAPI_PIPELINE_V4|$userId|resetBuildNo|$projectId|$pipelineId")
return client.get(ServicePipelineVersionResource::class).resetBuildNo(
userId = userId,
projectId = projectId,
pipelineId = pipelineId,
buildNo = buildNo
pipelineId = pipelineId
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import com.tencent.devops.common.api.pojo.Page
import com.tencent.devops.common.api.pojo.Result
import com.tencent.devops.common.pipeline.PipelineVersionWithModel
import com.tencent.devops.common.pipeline.PipelineVersionWithModelRequest
import com.tencent.devops.common.pipeline.pojo.BuildNoUpdateReq
import com.tencent.devops.common.pipeline.pojo.TemplateInstanceCreateRequest
import com.tencent.devops.common.pipeline.pojo.transfer.PreviewResponse
import com.tencent.devops.process.engine.pojo.PipelineVersionWithInfo
Expand Down Expand Up @@ -318,8 +317,8 @@ interface ServicePipelineVersionResource {

@Operation(summary = "重置流水线推荐版本号")
@POST
@Path("/projects/{projectId}/pipelines/{pipelineId}/updateBuildNo")
fun updateBuildNo(
@Path("/projects/{projectId}/pipelines/{pipelineId}/resetBuildNo")
fun resetBuildNo(
@Parameter(description = "用户ID", required = true, example = AUTH_HEADER_USER_ID_DEFAULT_VALUE)
@HeaderParam(AUTH_HEADER_USER_ID)
userId: String,
Expand All @@ -328,8 +327,6 @@ interface ServicePipelineVersionResource {
projectId: String,
@Parameter(description = "流水线ID", required = true)
@PathParam("pipelineId")
pipelineId: String,
@Parameter(description = "流水线构建推荐版本号更新", required = true)
buildNo: BuildNoUpdateReq
pipelineId: String
): Result<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import com.tencent.devops.common.auth.api.AuthResourceType
import com.tencent.devops.common.pipeline.PipelineVersionWithModel
import com.tencent.devops.common.pipeline.PipelineVersionWithModelRequest
import com.tencent.devops.common.pipeline.enums.PipelineStorageType
import com.tencent.devops.common.pipeline.pojo.BuildNoUpdateReq
import com.tencent.devops.common.pipeline.pojo.TemplateInstanceCreateRequest
import com.tencent.devops.common.web.RestResource
import com.tencent.devops.common.web.utils.I18nUtil
Expand Down Expand Up @@ -452,20 +451,17 @@ class ServicePipelineVersionResourceImpl @Autowired constructor(
)
}

override fun updateBuildNo(
override fun resetBuildNo(
userId: String,
projectId: String,
pipelineId: String,
buildNo: BuildNoUpdateReq
): Result<Boolean> {
pipelineInfoFacadeService.updateBuildNo(
pipelineId: String
) = Result(
pipelineInfoFacadeService.resetBuildNo(
userId = userId,
projectId = projectId,
pipelineId = pipelineId,
buildNo = buildNo
pipelineId = pipelineId
)
return Result(true)
}
)

private fun checkParam(userId: String, projectId: String) {
if (userId.isBlank()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,37 @@ class PipelineInfoFacadeService @Autowired constructor(
)
}

fun resetBuildNo(
userId: String,
projectId: String,
pipelineId: String
): Boolean {
val releaseVersion = pipelineRepositoryService.getPipelineResourceVersion(projectId, pipelineId)
?: throw ErrorCodeException(
statusCode = Response.Status.NOT_FOUND.statusCode,
errorCode = ProcessMessageCode.ERROR_PIPELINE_MODEL_NOT_EXISTS
)
val buildNo = releaseVersion.model.getTriggerContainer().buildNo
?: return false
operationLogService.addOperationLog(
userId = userId,
projectId = projectId,
pipelineId = pipelineId,
version = 0,
operationLogType = OperationLogType.RESET_RECOMMENDED_VERSION_BUILD_NO,
params = buildNo.buildNo.toString(),
description = null
)
pipelineBuildSummaryDao.updateBuildNo(
dslContext = dslContext,
projectId = projectId,
pipelineId = pipelineId,
buildNo = buildNo.buildNo,
debug = false
)
return true
}

fun saveAll(
userId: String,
projectId: String,
Expand Down

0 comments on commit 1d18f27

Please sign in to comment.