From dad4e00d126bc7fe40f2ffe4257b7b9f92175eee Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 20 Sep 2024 11:08:56 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=8E=A8=E8=8D=90=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7=E4=BC=98=E5=8C=96=20#10958=20=E6=8E=A8?= =?UTF-8?q?=E8=8D=90=E7=89=88=E6=9C=AC=E5=8F=B7=E8=BF=94=E5=9B=9E=E4=B8=8A?= =?UTF-8?q?=E6=AC=A1=E6=9E=84=E5=BB=BA=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/process/utils/PipelineVarUtil.kt | 4 ++++ .../process/service/builds/PipelineBuildFacadeService.kt | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt index ba94030ae69..0cb81906e16 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/utils/PipelineVarUtil.kt @@ -534,4 +534,8 @@ object PipelineVarUtil { return "$majorVersion.$minorVersion.$fixVersion" } + + fun recommendVersionKey(key: String): Boolean { + return key == MAJORVERSION || key == MINORVERSION || key == FIXVERSION + } } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index 0d834efc14d..2c894ceda4f 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -136,6 +136,7 @@ import com.tencent.devops.process.utils.PIPELINE_RETRY_COUNT import com.tencent.devops.process.utils.PIPELINE_RETRY_START_TASK_ID import com.tencent.devops.process.utils.PIPELINE_SKIP_FAILED_TASK import com.tencent.devops.process.utils.PIPELINE_START_TASK_ID +import com.tencent.devops.process.utils.PipelineVarUtil.recommendVersionKey import com.tencent.devops.process.yaml.PipelineYamlFacadeService import com.tencent.devops.quality.api.v2.pojo.ControlPointPosition import org.slf4j.LoggerFactory @@ -252,12 +253,12 @@ class PipelineBuildFacadeService( val latestParamsMap = lastTimeInfo.buildParameters!!.associate { it.key to it.value } triggerContainer.params.forEach { param -> val realValue = latestParamsMap[param.id] - // 有上一次的构建参数的时候才设置成默认值,否者依然使用默认值。 + // 入参、推荐版本号参数有上一次的构建参数的时候才设置成默认值,否者依然使用默认值 // 当值是boolean类型的时候,需要转为boolean类型 param.value = if (param.constant == true) { param.readOnly = true param.defaultValue - } else if (!param.required) { + } else if (!param.required || !recommendVersionKey(param.id)) { param.defaultValue } else if (param.defaultValue is Boolean) { realValue?.toString()?.toBoolean()