Skip to content

Commit

Permalink
Merge pull request TencentBlueKing#10136 from yjieliang/bug-10095
Browse files Browse the repository at this point in the history
bug:解决stage审核参数值类型不一致问题 TencentBlueKing#10095
  • Loading branch information
bkci-bot committed Jun 3, 2024
2 parents 111d4fe + a99db1b commit 37fe837
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ data class ManualReviewParam(
@get:Schema(title = "参数名", required = true)
var key: String = "",
@get:Schema(title = "参数内容(Any 类型)", required = true, type = "string")
var value: Any? = "",
var value: Any? = null,
@get:Schema(title = "参数类型", required = false)
val valueType: ManualReviewParamType = ManualReviewParamType.STRING,
@get:Schema(title = "是否必填", required = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import com.tencent.devops.process.engine.dao.PipelineResourceDao
import com.tencent.devops.process.engine.dao.PipelineResourceVersionDao
import com.tencent.devops.process.engine.pojo.event.PipelineBuildWebSocketPushEvent
import com.tencent.devops.process.engine.service.PipelineElementService
import com.tencent.devops.process.engine.utils.PipelineUtils
import com.tencent.devops.process.pojo.BuildStageStatus
import com.tencent.devops.process.pojo.pipeline.record.BuildRecordModel
import com.tencent.devops.process.pojo.pipeline.record.BuildRecordStage
Expand Down Expand Up @@ -189,6 +190,9 @@ open class BaseBuildRecordService(
return try {
watcher.start("fillElementWhenNewBuild")
val fullModel = JsonUtil.to(resourceStr, Model::class.java)
fullModel.stages.forEach {
PipelineUtils.transformUserIllegalReviewParams(it.checkIn?.reviewParams)
}
val baseModelMap = JsonUtil.toMutableMap(bean = fullModel, skipEmpty = false)
val mergeBuildRecordParam = MergeBuildRecordParam(
projectId = projectId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ object PipelineUtils {
}
}

fun transformUserIllegalReviewParams(reviewParams: List<ManualReviewParam>?) {
reviewParams?.forEach { param ->
val value = param.value
if (param.valueType == ManualReviewParamType.MULTIPLE && value is String && value.isBlank()) {
param.value = null
}
}
}

private fun checkVariablesLength(key: String, value: String) {
if (value.length >= PIPELINE_VARIABLES_STRING_LENGTH_MAX) {
throw ErrorCodeException(
Expand Down

0 comments on commit 37fe837

Please sign in to comment.