diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineWebhookService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineWebhookService.kt index 649a921ac02..2892566bd62 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineWebhookService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineWebhookService.kt @@ -56,6 +56,7 @@ import com.tencent.devops.process.pojo.PipelineNotifyTemplateEnum import com.tencent.devops.process.pojo.webhook.PipelineWebhook import com.tencent.devops.process.pojo.webhook.WebhookTriggerPipeline import com.tencent.devops.process.service.scm.ScmProxyService +import com.tencent.devops.process.utils.PipelineVarUtil import com.tencent.devops.repository.api.ServiceRepositoryResource import com.tencent.devops.repository.pojo.Repository import org.jooq.DSLContext @@ -95,9 +96,11 @@ class PipelineWebhookService @Autowired constructor( return } val triggerContainer = model.getTriggerContainer() - val variables = triggerContainer.params.associate { param -> - param.id to param.defaultValue.toString() - }.toMutableMap() + val variables = PipelineVarUtil.fillVariableMap( + triggerContainer.params.associate { param -> + param.id to param.defaultValue.toString() + } + ) val elements = triggerContainer.elements.filterIsInstance() val failedElementNames = mutableListOf() elements.forEach { element -> diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineWebhookUpgradeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineWebhookUpgradeService.kt index b17fd2dbb31..cb5c5bb8fef 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineWebhookUpgradeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineWebhookUpgradeService.kt @@ -42,6 +42,7 @@ import com.tencent.devops.common.pipeline.utils.RepositoryConfigUtils import com.tencent.devops.process.engine.dao.PipelineWebhookDao import com.tencent.devops.process.pojo.webhook.PipelineWebhook import com.tencent.devops.process.service.scm.ScmProxyService +import com.tencent.devops.process.utils.PipelineVarUtil import com.tencent.devops.repository.api.ServiceRepositoryResource import com.tencent.devops.repository.pojo.Repository import org.jooq.DSLContext @@ -336,9 +337,11 @@ class PipelineWebhookUpgradeService( return } val triggerContainer = model.getTriggerContainer() - val params = triggerContainer.params.associate { param -> - param.id to param.defaultValue.toString() - } + val params = PipelineVarUtil.fillVariableMap( + triggerContainer.params.associate { param -> + param.id to param.defaultValue.toString() + } + ) val elementMap = triggerContainer.elements.filterIsInstance().associateBy { it.id } val pipelineWebhooks = pipelineWebhookDao.listWebhook( diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/RepoPipelineRefService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/RepoPipelineRefService.kt index 8379eb70430..1a1774038e9 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/RepoPipelineRefService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/RepoPipelineRefService.kt @@ -51,6 +51,7 @@ import com.tencent.devops.common.pipeline.utils.RepositoryConfigUtils import com.tencent.devops.process.engine.dao.PipelineInfoDao import com.tencent.devops.process.engine.dao.PipelineModelTaskDao import com.tencent.devops.process.engine.dao.PipelineResourceDao +import com.tencent.devops.process.utils.PipelineVarUtil import com.tencent.devops.repository.api.ServiceRepositoryResource import com.tencent.devops.repository.pojo.RepoPipelineRefInfo import com.tencent.devops.repository.pojo.RepoPipelineRefRequest @@ -201,7 +202,7 @@ class RepoPipelineRefService @Autowired constructor( channel: String ) { val repoPipelineRefInfos = mutableListOf() - val variables = mutableMapOf() + var variables = mutableMapOf() model?.stages?.forEachIndexed { index, stage -> if (index == 0) { val container = stage.containers[0] as TriggerContainer @@ -209,6 +210,8 @@ class RepoPipelineRefService @Autowired constructor( container.params.forEach { param -> variables[param.id] = param.defaultValue.toString() } + // 填充[variables.]前缀 + variables = PipelineVarUtil.fillVariableMap(variables).toMutableMap() analysisTriggerContainer( projectId = projectId, pipelineId = pipelineId, diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/webhook/PipelineBuildWebhookService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/webhook/PipelineBuildWebhookService.kt index 0fec9077ab2..b122030cd26 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/webhook/PipelineBuildWebhookService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/webhook/PipelineBuildWebhookService.kt @@ -242,7 +242,7 @@ class PipelineBuildWebhookService @Autowired constructor( return@elements } val webHookParams = WebhookElementParamsRegistrar.getService(element) - .getWebhookElementParams(element, variables) ?: return@elements + .getWebhookElementParams(element, PipelineVarUtil.fillVariableMap(variables)) ?: return@elements val repositoryConfig = webHookParams.repositoryConfig if (repositoryConfig.getRepositoryId().isBlank()) { logger.info("repositoryHashId is blank for code trigger pipeline $pipelineId ") @@ -418,7 +418,7 @@ class PipelineBuildWebhookService @Autowired constructor( taskIds.forEach { taskId -> val triggerElement = triggerElementMap[taskId] ?: return@forEach val webHookParams = WebhookElementParamsRegistrar.getService(triggerElement) - .getWebhookElementParams(triggerElement, variables) ?: return@forEach + .getWebhookElementParams(triggerElement, PipelineVarUtil.fillVariableMap(variables)) ?: return@forEach val repositoryConfig = webHookParams.repositoryConfig if (repositoryConfig.repositoryHashId.isNullOrBlank() && repositoryConfig.repositoryName.isNullOrBlank()) { logger.info("repositoryHashId is blank for code trigger pipeline $pipelineId ") diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/yaml/PipelineYamlRepositoryService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/yaml/PipelineYamlRepositoryService.kt index 452c651b65f..503d7b2153b 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/yaml/PipelineYamlRepositoryService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/yaml/PipelineYamlRepositoryService.kt @@ -45,6 +45,7 @@ import com.tencent.devops.process.pojo.pipeline.enums.PipelineYamlStatus import com.tencent.devops.process.pojo.webhook.PipelineWebhookVersion import com.tencent.devops.process.service.PipelineInfoFacadeService import com.tencent.devops.process.service.view.PipelineViewGroupService +import com.tencent.devops.process.utils.PipelineVarUtil import com.tencent.devops.process.yaml.actions.BaseAction import com.tencent.devops.process.yaml.actions.GitActionCommon import com.tencent.devops.process.yaml.actions.internal.PipelineYamlManualAction @@ -703,9 +704,11 @@ class PipelineYamlRepositoryService @Autowired constructor( return emptyList() } val triggerContainer = model.getTriggerContainer() - val variables = triggerContainer.params.associate { param -> - param.id to param.defaultValue.toString() - }.toMutableMap() + val variables = PipelineVarUtil.fillVariableMap( + triggerContainer.params.associate { param -> + param.id to param.defaultValue.toString() + } + ).toMutableMap() // 补充yaml流水线代码库信息 variables[PIPELINE_PAC_REPO_HASH_ID] = repoHashId