Skip to content

Commit

Permalink
feat:流水线变量语法支持两种风格 #10576
Browse files Browse the repository at this point in the history
  • Loading branch information
mingshewhe committed Sep 30, 2024
1 parent 525b136 commit 3619029
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,11 @@ open class DefaultModelCheckPlugin constructor(
val triggerContainer = (trigger.containers.getOrNull(0) ?: throw ErrorCodeException(
errorCode = ProcessMessageCode.ERROR_PIPELINE_MODEL_NEED_JOB
)) as TriggerContainer
return PipelineUtils.checkPipelineParams(triggerContainer.params)
return if (supportChineseVarName != false) {
triggerContainer.params.associateBy { it.id }
} else {
PipelineUtils.checkPipelineParams(triggerContainer.params)
}
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import com.tencent.devops.common.pipeline.pojo.element.market.MarketBuildLessAto
import com.tencent.devops.common.web.utils.I18nUtil
import com.tencent.devops.process.constant.ProcessMessageCode
import com.tencent.devops.process.engine.dao.PipelineResourceDao
import com.tencent.devops.process.engine.extend.DefaultModelCheckPlugin
import com.tencent.devops.process.engine.service.PipelineRepositoryService
import com.tencent.devops.process.permission.PipelinePermissionService
import com.tencent.devops.process.utils.PipelineVarUtil
Expand All @@ -33,7 +32,6 @@ class SubPipelineRepositoryService @Autowired constructor(
private val objectMapper: ObjectMapper,
private val pipelineResDao: PipelineResourceDao,
private val pipelineRepositoryService: PipelineRepositoryService,
private val defaultModelCheckPlugin: DefaultModelCheckPlugin,
private val pipelinePermissionService: PipelinePermissionService
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import com.tencent.devops.common.api.util.JsonUtil
import com.tencent.devops.common.api.util.MessageUtil
import com.tencent.devops.common.pipeline.EnvReplacementParser
import com.tencent.devops.common.pipeline.NameAndValue
import com.tencent.devops.common.pipeline.dialect.PipelineDialectUtil
import com.tencent.devops.common.pipeline.enums.BuildFormPropertyType
import com.tencent.devops.common.pipeline.enums.BuildTaskStatus
import com.tencent.devops.common.pipeline.pojo.BuildParameters
Expand All @@ -45,6 +46,7 @@ import com.tencent.devops.process.engine.common.VMUtils
import com.tencent.devops.process.pojo.BuildJobResult
import com.tencent.devops.process.pojo.BuildTask
import com.tencent.devops.process.pojo.BuildVariables
import com.tencent.devops.process.utils.PIPELINE_DIALECT
import com.tencent.devops.process.utils.PIPELINE_RETRY_COUNT
import com.tencent.devops.process.utils.PipelineVarUtil
import com.tencent.devops.worker.common.constants.WorkerMessageCode.BK_PREPARE_TO_BUILD
Expand Down Expand Up @@ -443,6 +445,7 @@ object Runner {

// 填充插件级的ENV参数
val customEnvStr = buildTask.params?.get(Element::customEnv.name)
val dialect = PipelineDialectUtil.getPipelineDialect(jobBuildVariables.variables[PIPELINE_DIALECT])
if (customEnvStr != null) {
val customEnv = try {
JsonUtil.toOrNull(customEnvStr, object : TypeReference<List<NameAndValue>>() {})
Expand All @@ -458,6 +461,7 @@ object Runner {
val value = EnvReplacementParser.parse(
value = it.value ?: "",
contextMap = jobVariables,
dialect = dialect,
functions = SpecialFunctions.functions,
output = SpecialFunctions.output
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ import java.util.stream.Collectors

@Suppress("NestedBlockDepth", "TooManyFunctions")
abstract class ITask {

private val logger = LoggerFactory.getLogger(ITask::class.java)

private val environment = HashMap<String, String>()

private val monitorData = HashMap<String, Any>()
Expand Down

0 comments on commit 3619029

Please sign in to comment.