Skip to content

Commit

Permalink
【蓝盾-评审会已评审】【PAC】feat:新建/编辑流水线支持以 Code 方式编排流水线 TencentBlueKing#8125
Browse files Browse the repository at this point in the history
  • Loading branch information
yongyiduan committed Aug 14, 2023
1 parent 5a74846 commit 3d4ed13
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ package com.tencent.devops.process.yaml.modelTransfer.inner

import com.tencent.devops.common.pipeline.pojo.element.ElementAdditionalOptions
import com.tencent.devops.common.pipeline.pojo.element.market.MarketBuildAtomElement
import com.tencent.devops.process.yaml.v2.models.job.Job
import com.tencent.devops.process.yaml.v2.models.step.Step

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ import javax.ws.rs.core.Response
@Component
class TransferModelCreatorImpl @Autowired constructor(
) : TransferModelCreator {
@Value("\${stream.marketRun.enable:#{false}}")
@Value("\${marketRun.enable:#{false}}")
private val marketRunTaskData: Boolean = false

@Value("\${stream.marketRun.atomCode:#{null}}")
@Value("\${marketRun.atomCode:#{null}}")
private val runPlugInAtomCodeData: String? = null

@Value("\${stream.marketRun.atomVersion:#{null}}")
@Value("\${marketRun.atomVersion:#{null}}")
private val runPlugInVersionData: String? = null

@Value("\${container.defaultImage:#{null}}")
Expand Down Expand Up @@ -91,7 +91,6 @@ class TransferModelCreatorImpl @Autowired constructor(

inputMap["repositoryUrl"] = step.checkout!!


// 用户未指定时缺省为 AUTH_USER_TOKEN 同时指定 开启人
if (inputMap["authType"] == null) {
inputMap["authType"] = STREAM_CHECK_AUTH_TYPE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ package com.tencent.devops.process.yaml.pojo
interface YamlVersion {
enum class Version {
V2_0,
V3_0
V3_0;

companion object {
const val V2 = "v2.0"
const val V3 = "v3.0"
}
}

fun yamlVersion(): Version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,27 @@ import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonSubTypes
import com.fasterxml.jackson.annotation.JsonTypeInfo
import com.tencent.devops.common.api.enums.ScmType
import com.tencent.devops.process.yaml.pojo.YamlVersion
import com.tencent.devops.process.yaml.v2.models.job.Job
import com.tencent.devops.process.yaml.v2.models.on.PreTriggerOn
import com.tencent.devops.process.yaml.v2.models.on.TriggerOn
import com.tencent.devops.process.yaml.v2.models.stage.Stage
import com.tencent.devops.process.yaml.v2.utils.ScriptYmlUtils

import com.tencent.devops.process.yaml.v3.models.PreTemplateScriptBuildYamlV3

@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "version",
defaultImpl = PreTemplateScriptBuildYaml::class
)
@JsonSubTypes(
JsonSubTypes.Type(value = PreTemplateScriptBuildYamlV3::class, name = YamlVersion.Version.V3),
JsonSubTypes.Type(value = PreTemplateScriptBuildYaml::class, name = YamlVersion.Version.V2)
)
interface IPreTemplateScriptBuildYaml : YamlVersion {
val version: String?
val name: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import com.tencent.devops.process.yaml.modelTransfer.pojo.ModelTransferInput
import com.tencent.devops.process.yaml.modelTransfer.pojo.YamlTransferInput
import com.tencent.devops.process.yaml.pojo.TemplatePath
import com.tencent.devops.process.yaml.pojo.YamlVersion
import com.tencent.devops.process.yaml.v2.models.IPreTemplateScriptBuildYaml
import com.tencent.devops.process.yaml.v2.models.PreTemplateScriptBuildYaml
import com.tencent.devops.process.yaml.v2.models.step.PreStep
import com.tencent.devops.process.yaml.v2.parsers.template.YamlTemplate
Expand Down Expand Up @@ -127,7 +128,7 @@ class PipelineTransferYamlService @Autowired constructor(
watcher.start("FULL_YAML2MODEL start")
val pipelineInfo = pipelineRepositoryService.getPipelineInfo(projectId, pipelineId)
val pYml = TransferMapper.getObjectMapper()
.readValue(data.oldYaml, object : TypeReference<PreTemplateScriptBuildYaml>() {})
.readValue(data.oldYaml, object : TypeReference<IPreTemplateScriptBuildYaml>() {})
watcher.start("parse template")
pYml.replaceTemplate { templateFilter ->
YamlTemplate(
Expand Down

0 comments on commit 3d4ed13

Please sign in to comment.