Skip to content

Commit

Permalink
Merge pull request #10287 from royalhuang/pac_github
Browse files Browse the repository at this point in the history
feat:流水线版本管理机制 #8161 流水线名称逻辑修复
  • Loading branch information
bkci-bot authored Apr 30, 2024
2 parents df2b1d3 + f95dd30 commit bebead9
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class ModelTransfer @Autowired constructor(
projectId = yamlInput.pipelineInfo?.projectId ?: "",
pipelineId = yamlInput.pipelineInfo?.pipelineId ?: "",
buildNumRule = yaml.customBuildNum,
pipelineName = yaml.name ?: yamlInput.pipelineInfo?.pipelineName ?: "",
// 如果yaml内容缺失,先用pac文件名兜底,没有文件名才用原流水线名
pipelineName = yaml.name ?: yamlInput.yamlFileName ?: yamlInput.pipelineInfo?.pipelineName ?: "",
desc = yaml.desc ?: yamlInput.pipelineInfo?.pipelineDesc ?: "",
concurrencyGroup = yaml.concurrency?.group ?: PIPELINE_SETTING_CONCURRENCY_GROUP_DEFAULT,
// Cancel-In-Progress 配置group后默认为true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ data class YamlTransferInput(
val userId: String,
val projectCode: String,
val pipelineInfo: PipelineInfo?,
val yamlFileName: String?,
val yaml: IPreTemplateScriptBuildYamlParser,
val aspectWrapper: PipelineTransferAspectWrapper,
val defaultScmType: ScmType = ScmType.CODE_GIT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ data class TransferBody(
@get:Schema(title = "当前modelAndSetting,model转yaml时需带上")
val modelAndSetting: PipelineModelAndSetting? = null,
@get:Schema(title = "当前yaml内容,model转yaml以及yaml转model都需要带上,如果首次互转没有就传空")
val oldYaml: String = ""
val oldYaml: String = "",
@get:Schema(title = "yaml内容的来源yaml文件名(用于流水线名称的缺省值)")
val yamlFileName: String? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ class PipelineResourceVersionDao {
name -> name != "init"
} ?: PipelineVersionUtils.getVersionName(
versionNum, record.version, record.triggerVersion, record.settingVersion
) ?: "V$versionNum(${record.versionName}"
) ?: "V$versionNum(${record.versionName})"
PipelineResourceVersion(
projectId = record.projectId,
pipelineId = record.pipelineId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1620,13 +1620,12 @@ class PipelineRuntimeService @Autowired constructor(
pipelineId = latestRunningBuild.pipelineId,
queueIncrement = -1
)
} else {
pipelineBuildSummaryDao.finishLatestRunningBuild(
dslContext = dslContext,
latestRunningBuild = latestRunningBuild,
isStageFinish = currentBuildStatus.name == BuildStatus.STAGE_SUCCESS.name
)
}
pipelineBuildSummaryDao.finishLatestRunningBuild(
dslContext = dslContext,
latestRunningBuild = latestRunningBuild,
isStageFinish = currentBuildStatus.name == BuildStatus.STAGE_SUCCESS.name
)
}
with(latestRunningBuild) {
val executeTime = try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ class PipelineTransferYamlService @Autowired constructor(
projectCode = projectId,
pipelineInfo = pipelineInfo,
yaml = pYml,
yamlFileName = data.yamlFileName,
asCodeSettings = data.modelAndSetting?.setting?.pipelineAsCodeSettings,
aspectWrapper = PipelineTransferAspectWrapper(aspects)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ class PipelineInfoFacadeService @Autowired constructor(
userId = userId,
projectId = projectId,
yaml = yaml,
yamlFileName = yamlFileName,
isDefaultBranch = isDefaultBranch,
branchName = branchName,
aspects = aspects
Expand Down Expand Up @@ -610,6 +611,7 @@ class PipelineInfoFacadeService @Autowired constructor(
userId = userId,
projectId = projectId,
yaml = yaml,
yamlFileName = yamlFileName,
isDefaultBranch = isDefaultBranch,
branchName = branchName,
aspects = aspects
Expand Down Expand Up @@ -723,6 +725,7 @@ class PipelineInfoFacadeService @Autowired constructor(
userId: String,
projectId: String,
yaml: String,
yamlFileName: String,
isDefaultBranch: Boolean,
branchName: String,
aspects: LinkedList<IPipelineTransferAspect>? = null
Expand All @@ -733,7 +736,7 @@ class PipelineInfoFacadeService @Autowired constructor(
projectId = projectId,
pipelineId = null,
actionType = TransferActionType.FULL_YAML2MODEL,
data = TransferBody(oldYaml = yaml),
data = TransferBody(oldYaml = yaml, yamlFileName = yamlFileName),
aspects = aspects ?: LinkedList()
)
if (result.modelAndSetting == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,23 +324,25 @@ class PipelineVersionFacadeService @Autowired constructor(
Pair(VersionStatus.DRAFT_RELEASE, null)
}
if (enabled) {
if (request.yamlInfo == null) throw ErrorCodeException(
errorCode = CommonMessageCode.ERROR_NEED_PARAM_,
params = arrayOf(PipelineVersionReleaseRequest::yamlInfo.name)
)
if (draftVersion.yaml.isNullOrBlank()) {
transferService.transfer(
userId = userId,
projectId = projectId,
pipelineId = pipelineId,
actionType = TransferActionType.FULL_MODEL2YAML,
data = TransferBody(PipelineModelAndSetting(draftVersion.model, targetSettings))
data = TransferBody(
modelAndSetting = PipelineModelAndSetting(draftVersion.model, targetSettings),
yamlFileName = request.yamlInfo?.filePath
)
)
throw ErrorCodeException(
errorCode = ProcessMessageCode.ERROR_YAML_CONTENT_IS_EMPTY
)
}

if (request.yamlInfo == null) throw ErrorCodeException(
errorCode = CommonMessageCode.ERROR_NEED_PARAM_,
params = arrayOf(PipelineVersionReleaseRequest::yamlInfo.name)
)
val yamlInfo = request.yamlInfo ?: throw ErrorCodeException(
errorCode = CommonMessageCode.ERROR_NEED_PARAM_,
params = arrayOf(PipelineVersionReleaseRequest::yamlInfo.name)
Expand Down

0 comments on commit bebead9

Please sign in to comment.