From e358f413619594c4cb9743786e4431ec934a0759 Mon Sep 17 00:00:00 2001 From: yjieliang Date: Thu, 9 Jan 2025 17:36:02 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E5=92=8C=E6=9E=84=E5=BB=BA=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E9=85=8D=E7=BD=AE=E7=95=8C=E9=9D=A2=E6=95=8F?= =?UTF-8?q?=E6=84=9F=E5=AD=97=E6=AE=B5=E5=B1=95=E7=A4=BA=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20#11019?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pipeline/PipelineTransferYamlService.kt | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/pipeline/PipelineTransferYamlService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/pipeline/PipelineTransferYamlService.kt index 0cc5c425863..53a53af61f5 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/pipeline/PipelineTransferYamlService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/service/pipeline/PipelineTransferYamlService.kt @@ -284,16 +284,20 @@ class PipelineTransferYamlService @Autowired constructor( val triggerIndex = mutableListOf() val noticeIndex = mutableListOf() val settingIndex = mutableListOf() - val yaml = resource.yaml ?: transfer( - userId = userId, - projectId = projectId, - pipelineId = pipelineId, - actionType = TransferActionType.FULL_MODEL2YAML, - data = TransferBody(modelAndSetting), - editPermission = editPermission - ).yamlWithVersion?.yamlStr ?: return PreviewResponse("") + val yaml = if (editPermission == false || resource.yaml.isNullOrBlank()) { + transfer( + userId = userId, + projectId = projectId, + pipelineId = pipelineId, + actionType = TransferActionType.FULL_MODEL2YAML, + data = TransferBody(modelAndSetting), + editPermission = editPermission + ).yamlWithVersion?.yamlStr ?: return PreviewResponse("") + } else { + resource.yaml + } try { - TransferMapper.getYamlLevelOneIndex(yaml).forEach { (key, value) -> + TransferMapper.getYamlLevelOneIndex(yaml!!).forEach { (key, value) -> if (key in pipeline_key) pipelineIndex.add(value) if (key in trigger_key) triggerIndex.add(value) if (key in notice_key) noticeIndex.add(value) @@ -302,7 +306,7 @@ class PipelineTransferYamlService @Autowired constructor( } catch (ignore: Throwable) { logger.warn("TRANSFER_YAML|$projectId|$userId", ignore) } - return PreviewResponse(yaml, pipelineIndex, triggerIndex, noticeIndex, settingIndex) + return PreviewResponse(yaml!!, pipelineIndex, triggerIndex, noticeIndex, settingIndex) } fun position(