From 5b6cf938c57a072998cf28296ba5976f55cf7783 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 24 Nov 2023 00:18:04 +0800 Subject: [PATCH 01/25] =?UTF-8?q?feat=EF=BC=9A=E7=BA=A6=E6=9D=9F=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E7=9A=84=E6=A8=A1=E7=89=88=E5=AE=9E=E4=BE=8B=EF=BC=8C?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=BA=90=E6=A8=A1=E7=89=88=E7=89=88=E6=9C=AC=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=20#9700?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/engine/pojo/PipelineInfo.kt | 5 +- .../process/pojo/pipeline/ModelRecord.kt | 4 +- .../process/pojo/pipeline/TemplateInfo.kt | 46 +++++++++++++++++++ .../service/PipelineRepositoryService.kt | 19 +++++++- .../record/PipelineBuildRecordService.kt | 3 +- 5 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/TemplateInfo.kt diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/engine/pojo/PipelineInfo.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/engine/pojo/PipelineInfo.kt index 10556b02d9f..d5b8254fc98 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/engine/pojo/PipelineInfo.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/engine/pojo/PipelineInfo.kt @@ -28,6 +28,7 @@ package com.tencent.devops.process.engine.pojo import com.tencent.devops.common.pipeline.enums.ChannelCode +import com.tencent.devops.process.pojo.pipeline.TemplateInfo import io.swagger.annotations.ApiModel import io.swagger.annotations.ApiModelProperty @@ -66,5 +67,7 @@ data class PipelineInfo( @ApiModelProperty("ID") val id: Long?, @ApiModelProperty("流水线组名称列表", required = false) - var viewNames: List? = null + var viewNames: List? = null, + @ApiModelProperty("约束模式下的模板信息", required = false) + var templateInfo: TemplateInfo? = null ) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/ModelRecord.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/ModelRecord.kt index c39618b344f..e1c68be178d 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/ModelRecord.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/ModelRecord.kt @@ -95,5 +95,7 @@ data class ModelRecord( @ApiModelProperty("备注", required = false) val remark: String?, @ApiModelProperty("触发信息(包括代码库等)", required = false) - val webhookInfo: WebhookInfo? + val webhookInfo: WebhookInfo?, + @ApiModelProperty("约束模式下的模板信息", required = false) + var templateInfo: TemplateInfo? = null ) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/TemplateInfo.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/TemplateInfo.kt new file mode 100644 index 00000000000..aa5d4fd3604 --- /dev/null +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/TemplateInfo.kt @@ -0,0 +1,46 @@ +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. + * + * A copy of the MIT License is included in this file. + * + * + * Terms of the MIT License: + * --------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.tencent.devops.process.pojo.pipeline + +import com.tencent.devops.common.pipeline.enums.PipelineInstanceTypeEnum +import io.swagger.annotations.ApiModel +import io.swagger.annotations.ApiModelProperty + +@ApiModel("子流水线参数键值对") +data class TemplateInfo( + @ApiModelProperty("模板ID", required = true) + val templateId: String, + @ApiModelProperty("版本号", required = true) + val version: Long, + @ApiModelProperty("版本名称", required = true) + val versionName: String, + @ApiModelProperty("关联模式", required = true) + val instanceType: PipelineInstanceTypeEnum, + @ApiModelProperty("版本描述", required = true) + val desc: String? = null +) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt index 3cbad8ea9f2..0fede17cb56 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt @@ -45,6 +45,7 @@ import com.tencent.devops.common.pipeline.container.Stage import com.tencent.devops.common.pipeline.container.TriggerContainer import com.tencent.devops.common.pipeline.container.VMBuildContainer import com.tencent.devops.common.pipeline.enums.ChannelCode +import com.tencent.devops.common.pipeline.enums.PipelineInstanceTypeEnum import com.tencent.devops.common.pipeline.extend.ModelCheckPlugin import com.tencent.devops.common.pipeline.option.MatrixControlOption import com.tencent.devops.common.pipeline.pojo.BuildNo @@ -70,6 +71,7 @@ import com.tencent.devops.process.engine.dao.PipelineInfoDao import com.tencent.devops.process.engine.dao.PipelineModelTaskDao import com.tencent.devops.process.engine.dao.PipelineResDao import com.tencent.devops.process.engine.dao.PipelineResVersionDao +import com.tencent.devops.process.engine.dao.template.TemplateDao import com.tencent.devops.process.engine.dao.template.TemplatePipelineDao import com.tencent.devops.process.engine.pojo.PipelineInfo import com.tencent.devops.process.engine.pojo.PipelineModelTask @@ -84,6 +86,7 @@ import com.tencent.devops.process.pojo.PipelineSortType import com.tencent.devops.process.pojo.pipeline.DeletePipelineResult import com.tencent.devops.process.pojo.pipeline.DeployPipelineResult import com.tencent.devops.process.pojo.pipeline.PipelineSubscriptionType +import com.tencent.devops.process.pojo.pipeline.TemplateInfo import com.tencent.devops.process.pojo.setting.PipelineModelVersion import com.tencent.devops.process.pojo.setting.PipelineRunLockType import com.tencent.devops.process.pojo.setting.PipelineSetting @@ -123,6 +126,7 @@ class PipelineRepositoryService constructor( private val pipelineJobMutexGroupService: PipelineJobMutexGroupService, private val modelCheckPlugin: ModelCheckPlugin, private val templatePipelineDao: TemplatePipelineDao, + private val templateDao: TemplateDao, private val pipelineResVersionDao: PipelineResVersionDao, private val pipelineSettingVersionDao: PipelineSettingVersionDao, private val pipelineViewGroupDao: PipelineViewGroupDao, @@ -757,8 +761,12 @@ class PipelineRepositoryService constructor( delete: Boolean? = false ): PipelineInfo? { val template = templatePipelineDao.get(dslContext, projectId, pipelineId) + val srcTemplate = template?.let { t -> + templateDao.getTemplate( + dslContext = dslContext, version = t.version) + } val templateId = template?.templateId - return pipelineInfoDao.convert( + val info = pipelineInfoDao.convert( t = pipelineInfoDao.getPipelineInfo( dslContext = dslContext, projectId = projectId, @@ -768,6 +776,15 @@ class PipelineRepositoryService constructor( ), templateId = templateId ) + if (info != null && srcTemplate != null) { + info.templateInfo = TemplateInfo( + templateId = srcTemplate.id, + version = srcTemplate.version, + versionName = srcTemplate.versionName, + instanceType = PipelineInstanceTypeEnum.valueOf(template.instanceType) + ) + } + return info } /** diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt index 686b10fb290..c8b630eb334 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt @@ -349,7 +349,8 @@ class PipelineBuildRecordService @Autowired constructor( ), material = buildInfo.material, remark = buildInfo.remark, - webhookInfo = buildInfo.webhookInfo + webhookInfo = buildInfo.webhookInfo, + templateInfo = pipelineInfo.templateInfo ) } From 045e801e87ec37adabea9f59ba90336c37c0907b Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 24 Nov 2023 10:07:21 +0800 Subject: [PATCH 02/25] =?UTF-8?q?feat:=20=E8=80=97=E6=97=B6=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=BC=98=E5=8C=96=20#9505?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/pojo/pipeline/BuildRecordInfo.kt | 40 +++++++++++++++++++ .../process/pojo/pipeline/ModelRecord.kt | 3 ++ .../process/dao/record/BuildRecordModelDao.kt | 11 ++--- .../record/PipelineBuildRecordService.kt | 18 +++++++-- 4 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/BuildRecordInfo.kt diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/BuildRecordInfo.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/BuildRecordInfo.kt new file mode 100644 index 00000000000..35908fb232e --- /dev/null +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/BuildRecordInfo.kt @@ -0,0 +1,40 @@ +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. + * + * A copy of the MIT License is included in this file. + * + * + * Terms of the MIT License: + * --------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.tencent.devops.process.pojo.pipeline + +import com.tencent.devops.common.pipeline.pojo.time.BuildRecordTimeCost +import io.swagger.annotations.ApiModel +import io.swagger.annotations.ApiModelProperty + +@ApiModel("执行次数记录") +data class BuildRecordInfo( + @ApiModelProperty("触发人", required = true) + val startUser: String, + @ApiModelProperty("耗时详情", required = true) + val timeCost: BuildRecordTimeCost? +) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/ModelRecord.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/ModelRecord.kt index e1c68be178d..9fff6311566 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/ModelRecord.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/ModelRecord.kt @@ -86,8 +86,11 @@ data class ModelRecord( val triggerReviewers: List? = null, @ApiModelProperty("当前查询的执行次数", required = false) val executeCount: Int, + @Deprecated("信息已在recordList中存在") @ApiModelProperty("历史重试执行人列表(有序)", required = true) val startUserList: List, + @ApiModelProperty("历史重试人列表(有序)", required = true) + val recordList: List, @ApiModelProperty("构建信息", required = false) var buildMsg: String?, @ApiModelProperty("原材料", required = false) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/record/BuildRecordModelDao.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/record/BuildRecordModelDao.kt index 38710facc3e..edf27dd08d9 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/record/BuildRecordModelDao.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/record/BuildRecordModelDao.kt @@ -37,8 +37,9 @@ import com.tencent.devops.model.process.tables.TPipelineBuildRecordModel import com.tencent.devops.model.process.tables.records.TPipelineBuildRecordModelRecord import com.tencent.devops.process.pojo.pipeline.record.BuildRecordModel import org.jooq.DSLContext +import org.jooq.Record2 import org.jooq.RecordMapper -import org.jooq.impl.DSL.select +import org.jooq.Result import org.springframework.stereotype.Repository import java.time.LocalDateTime @@ -137,19 +138,19 @@ class BuildRecordModelDao { } } - fun getRecordStartUserList( + fun getRecordInfoList( dslContext: DSLContext, projectId: String, pipelineId: String, buildId: String - ): List { + ): Result> { with(TPipelineBuildRecordModel.T_PIPELINE_BUILD_RECORD_MODEL) { - return dslContext.select(START_USER).from(this) + return dslContext.select(START_USER, MODEL_VAR).from(this) .where( BUILD_ID.eq(buildId) .and(PROJECT_ID.eq(projectId)) .and(PIPELINE_ID.eq(pipelineId)) - ).orderBy(EXECUTE_COUNT.desc()).fetch(START_USER) + ).orderBy(EXECUTE_COUNT.desc()).fetch() } } diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt index c8b630eb334..740b8e49c31 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt @@ -27,7 +27,9 @@ package com.tencent.devops.process.engine.service.record +import com.fasterxml.jackson.core.type.TypeReference import com.tencent.devops.common.api.pojo.ErrorInfo +import com.tencent.devops.common.api.util.JsonUtil import com.tencent.devops.common.api.util.Watcher import com.tencent.devops.common.api.util.timestampmilli import com.tencent.devops.common.event.dispatcher.pipeline.PipelineEventDispatcher @@ -70,6 +72,7 @@ import com.tencent.devops.process.engine.service.PipelineElementService import com.tencent.devops.process.engine.service.PipelineRepositoryService import com.tencent.devops.process.engine.utils.ContainerUtils import com.tencent.devops.process.pojo.BuildStageStatus +import com.tencent.devops.process.pojo.pipeline.BuildRecordInfo import com.tencent.devops.process.pojo.pipeline.ModelRecord import com.tencent.devops.process.pojo.pipeline.record.BuildRecordContainer import com.tencent.devops.process.pojo.pipeline.record.BuildRecordModel @@ -253,12 +256,18 @@ class PipelineBuildRecordService @Autowired constructor( buildId = buildId ) watcher.start("startUserList") - val startUserList = recordModelDao.getRecordStartUserList( + val recordList = recordModelDao.getRecordInfoList( dslContext = dslContext, pipelineId = pipelineInfo.pipelineId, projectId = projectId, buildId = buildId - ) + ).map { pair -> + val modelVar = JsonUtil.to( + pair.component2(), object : TypeReference>() {} + ).toMutableMap() + val timeCost = modelVar[Model::timeCost.name]?.let { it as BuildRecordTimeCost } + BuildRecordInfo(pair.component2(), timeCost) + } watcher.start("parseTriggerInfo") // TODO 临时解析旧触发器获取实际触发信息,后续触发器完善需要改回 val triggerInfo = if (buildInfo.trigger == StartType.WEB_HOOK.name) { @@ -341,7 +350,7 @@ class PipelineBuildRecordService @Autowired constructor( stageStatus = buildInfo.stageStatus, triggerReviewers = triggerReviewers, executeCount = fixedExecuteCount, - startUserList = startUserList, + startUserList = recordList.map { it.startUser }, buildMsg = BuildMsgUtils.getBuildMsg( buildMsg = buildInfo.buildMsg, startType = StartType.toStartType(buildInfo.trigger), @@ -350,7 +359,8 @@ class PipelineBuildRecordService @Autowired constructor( material = buildInfo.material, remark = buildInfo.remark, webhookInfo = buildInfo.webhookInfo, - templateInfo = pipelineInfo.templateInfo + templateInfo = pipelineInfo.templateInfo, + recordList = recordList ) } From 953e0ee895b492fad2bc49c930d4c37c90ce8b48 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 24 Nov 2023 10:30:56 +0800 Subject: [PATCH 03/25] =?UTF-8?q?feat:=20=E8=80=97=E6=97=B6=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=BC=98=E5=8C=96=20#9505?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/service/record/PipelineBuildRecordService.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt index 740b8e49c31..83b5b138ceb 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt @@ -265,7 +265,9 @@ class PipelineBuildRecordService @Autowired constructor( val modelVar = JsonUtil.to( pair.component2(), object : TypeReference>() {} ).toMutableMap() - val timeCost = modelVar[Model::timeCost.name]?.let { it as BuildRecordTimeCost } + val timeCost = modelVar[Model::timeCost.name]?.let { + JsonUtil.anyTo(it, object : TypeReference() {}) + } BuildRecordInfo(pair.component2(), timeCost) } watcher.start("parseTriggerInfo") From eae1508414ae2eff4bd360be43624a8547dcd19f Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 24 Nov 2023 11:00:29 +0800 Subject: [PATCH 04/25] =?UTF-8?q?feat:=20=E8=80=97=E6=97=B6=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=BC=98=E5=8C=96=20#9505?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/dao/record/BuildRecordModelDao.kt | 16 ++++++++++++++-- .../service/record/PipelineBuildRecordService.kt | 13 +------------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/record/BuildRecordModelDao.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/record/BuildRecordModelDao.kt index edf27dd08d9..558d1a4a546 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/record/BuildRecordModelDao.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/record/BuildRecordModelDao.kt @@ -30,11 +30,14 @@ package com.tencent.devops.process.dao.record import com.fasterxml.jackson.core.type.TypeReference import com.tencent.devops.common.api.pojo.ErrorInfo import com.tencent.devops.common.api.util.JsonUtil +import com.tencent.devops.common.pipeline.Model import com.tencent.devops.common.pipeline.enums.BuildRecordTimeStamp import com.tencent.devops.common.pipeline.enums.BuildStatus +import com.tencent.devops.common.pipeline.pojo.time.BuildRecordTimeCost import com.tencent.devops.common.pipeline.pojo.time.BuildTimestampType import com.tencent.devops.model.process.tables.TPipelineBuildRecordModel import com.tencent.devops.model.process.tables.records.TPipelineBuildRecordModelRecord +import com.tencent.devops.process.pojo.pipeline.BuildRecordInfo import com.tencent.devops.process.pojo.pipeline.record.BuildRecordModel import org.jooq.DSLContext import org.jooq.Record2 @@ -143,14 +146,23 @@ class BuildRecordModelDao { projectId: String, pipelineId: String, buildId: String - ): Result> { + ): List { with(TPipelineBuildRecordModel.T_PIPELINE_BUILD_RECORD_MODEL) { return dslContext.select(START_USER, MODEL_VAR).from(this) .where( BUILD_ID.eq(buildId) .and(PROJECT_ID.eq(projectId)) .and(PIPELINE_ID.eq(pipelineId)) - ).orderBy(EXECUTE_COUNT.desc()).fetch() + ).orderBy(EXECUTE_COUNT.desc()) + .fetch().map { pair -> + val modelVar = JsonUtil.to( + pair.component2(), object : TypeReference>() {} + ).toMutableMap() + val timeCost = modelVar[Model::timeCost.name]?.let { + JsonUtil.anyTo(it, object : TypeReference() {}) + } + BuildRecordInfo(pair.component1(), timeCost) + } } } diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt index 83b5b138ceb..b49554e7d33 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt @@ -27,9 +27,7 @@ package com.tencent.devops.process.engine.service.record -import com.fasterxml.jackson.core.type.TypeReference import com.tencent.devops.common.api.pojo.ErrorInfo -import com.tencent.devops.common.api.util.JsonUtil import com.tencent.devops.common.api.util.Watcher import com.tencent.devops.common.api.util.timestampmilli import com.tencent.devops.common.event.dispatcher.pipeline.PipelineEventDispatcher @@ -72,7 +70,6 @@ import com.tencent.devops.process.engine.service.PipelineElementService import com.tencent.devops.process.engine.service.PipelineRepositoryService import com.tencent.devops.process.engine.utils.ContainerUtils import com.tencent.devops.process.pojo.BuildStageStatus -import com.tencent.devops.process.pojo.pipeline.BuildRecordInfo import com.tencent.devops.process.pojo.pipeline.ModelRecord import com.tencent.devops.process.pojo.pipeline.record.BuildRecordContainer import com.tencent.devops.process.pojo.pipeline.record.BuildRecordModel @@ -261,15 +258,7 @@ class PipelineBuildRecordService @Autowired constructor( pipelineId = pipelineInfo.pipelineId, projectId = projectId, buildId = buildId - ).map { pair -> - val modelVar = JsonUtil.to( - pair.component2(), object : TypeReference>() {} - ).toMutableMap() - val timeCost = modelVar[Model::timeCost.name]?.let { - JsonUtil.anyTo(it, object : TypeReference() {}) - } - BuildRecordInfo(pair.component2(), timeCost) - } + ) watcher.start("parseTriggerInfo") // TODO 临时解析旧触发器获取实际触发信息,后续触发器完善需要改回 val triggerInfo = if (buildInfo.trigger == StartType.WEB_HOOK.name) { From 8f45c8bd7d074411796a077f27a832ed8965fbfa Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 24 Nov 2023 15:10:50 +0800 Subject: [PATCH 05/25] =?UTF-8?q?feat:=20=E8=80=97=E6=97=B6=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=BC=98=E5=8C=96=20#9505?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/process/pojo/pipeline/TemplateInfo.kt | 2 ++ .../devops/process/engine/service/PipelineRepositoryService.kt | 1 + 2 files changed, 3 insertions(+) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/TemplateInfo.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/TemplateInfo.kt index aa5d4fd3604..e4939021361 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/TemplateInfo.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/pipeline/TemplateInfo.kt @@ -35,6 +35,8 @@ import io.swagger.annotations.ApiModelProperty data class TemplateInfo( @ApiModelProperty("模板ID", required = true) val templateId: String, + @ApiModelProperty("模板名称", required = true) + val templateName: String, @ApiModelProperty("版本号", required = true) val version: Long, @ApiModelProperty("版本名称", required = true) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt index 0fede17cb56..6c7e59463d8 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt @@ -779,6 +779,7 @@ class PipelineRepositoryService constructor( if (info != null && srcTemplate != null) { info.templateInfo = TemplateInfo( templateId = srcTemplate.id, + templateName = srcTemplate.templateName, version = srcTemplate.version, versionName = srcTemplate.versionName, instanceType = PipelineInstanceTypeEnum.valueOf(template.instanceType) From a56fcd860f7355747942c843f5cf7043f98f8479 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 24 Nov 2023 15:27:01 +0800 Subject: [PATCH 06/25] =?UTF-8?q?feat:=20=E8=80=97=E6=97=B6=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=BC=98=E5=8C=96=20#9505?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/api/user/UserBuildResource.kt | 19 +++++++++++++ .../process/dao/record/BuildRecordModelDao.kt | 2 -- .../record/PipelineBuildRecordService.kt | 15 ++++++----- .../process/api/UserBuildResourceImpl.kt | 22 +++++++++++++++ .../builds/PipelineBuildFacadeService.kt | 27 +++++++++++++++++++ 5 files changed, 77 insertions(+), 8 deletions(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserBuildResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserBuildResource.kt index 4fdfd8ada15..a5e2f16e90c 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserBuildResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/user/UserBuildResource.kt @@ -43,6 +43,7 @@ import com.tencent.devops.process.pojo.BuildHistoryRemark import com.tencent.devops.process.pojo.BuildId import com.tencent.devops.process.pojo.BuildManualStartupInfo import com.tencent.devops.process.pojo.ReviewParam +import com.tencent.devops.process.pojo.pipeline.BuildRecordInfo import com.tencent.devops.process.pojo.pipeline.ModelDetail import com.tencent.devops.process.pojo.pipeline.ModelRecord import io.swagger.annotations.Api @@ -260,6 +261,24 @@ interface UserBuildResource { executeCount: Int? ): Result + @ApiOperation("获取构建多次执行信息") + @GET + @Path("/projects/{projectId}/pipelines/{pipelineId}/builds/{buildId}/recordInfo") + fun getBuildRecordInfo( + @ApiParam(value = "用户ID", required = true, defaultValue = AUTH_HEADER_USER_ID_DEFAULT_VALUE) + @HeaderParam(AUTH_HEADER_USER_ID) + userId: String, + @ApiParam("项目ID", required = true) + @PathParam("projectId") + projectId: String, + @ApiParam("流水线ID", required = true) + @PathParam("pipelineId") + pipelineId: String, + @ApiParam("构建ID", required = true) + @PathParam("buildId") + buildId: String + ): Result> + @ApiOperation("获取构建详情") @GET // @Path("/projects/{projectId}/pipelines/{pipelineId}/buildNo/{buildNo}/detail") diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/record/BuildRecordModelDao.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/record/BuildRecordModelDao.kt index 558d1a4a546..9aabf2ae3ee 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/record/BuildRecordModelDao.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/dao/record/BuildRecordModelDao.kt @@ -40,9 +40,7 @@ import com.tencent.devops.model.process.tables.records.TPipelineBuildRecordModel import com.tencent.devops.process.pojo.pipeline.BuildRecordInfo import com.tencent.devops.process.pojo.pipeline.record.BuildRecordModel import org.jooq.DSLContext -import org.jooq.Record2 import org.jooq.RecordMapper -import org.jooq.Result import org.springframework.stereotype.Repository import java.time.LocalDateTime diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt index b49554e7d33..eb994218c61 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/record/PipelineBuildRecordService.kt @@ -253,12 +253,7 @@ class PipelineBuildRecordService @Autowired constructor( buildId = buildId ) watcher.start("startUserList") - val recordList = recordModelDao.getRecordInfoList( - dslContext = dslContext, - pipelineId = pipelineInfo.pipelineId, - projectId = projectId, - buildId = buildId - ) + val recordList = getRecordInfo(pipelineInfo.pipelineId, projectId, buildId) watcher.start("parseTriggerInfo") // TODO 临时解析旧触发器获取实际触发信息,后续触发器完善需要改回 val triggerInfo = if (buildInfo.trigger == StartType.WEB_HOOK.name) { @@ -355,6 +350,14 @@ class PipelineBuildRecordService @Autowired constructor( ) } + fun getRecordInfo(pipelineId: String, projectId: String, buildId: String) = + recordModelDao.getRecordInfoList( + dslContext = dslContext, + pipelineId = pipelineId, + projectId = projectId, + buildId = buildId + ) + private fun fixContainerDetail(container: Container) { container.containerHashId = container.containerHashId ?: container.containerId container.containerId = container.id diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt index f967d329217..4465d0d408f 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/UserBuildResourceImpl.kt @@ -46,6 +46,7 @@ import com.tencent.devops.process.pojo.BuildHistoryRemark import com.tencent.devops.process.pojo.BuildId import com.tencent.devops.process.pojo.BuildManualStartupInfo import com.tencent.devops.process.pojo.ReviewParam +import com.tencent.devops.process.pojo.pipeline.BuildRecordInfo import com.tencent.devops.process.pojo.pipeline.ModelDetail import com.tencent.devops.process.pojo.pipeline.ModelRecord import com.tencent.devops.process.service.PipelineRecentUseService @@ -294,6 +295,27 @@ class UserBuildResourceImpl @Autowired constructor( ) } + override fun getBuildRecordInfo( + userId: String, + projectId: String, + pipelineId: String, + buildId: String + ): Result> { + checkParam(userId, projectId, pipelineId) + if (buildId.isBlank()) { + throw ParamBlankException("Invalid buildId") + } + return Result( + pipelineBuildFacadeService.getBuildRecordInfo( + userId = userId, + projectId = projectId, + pipelineId = pipelineId, + buildId = buildId, + channelCode = ChannelCode.BS + ) + ) + } + override fun getBuildDetailByBuildNo( userId: String, projectId: String, diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt index 0f96076ecbf..c50f2c3e8a4 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/builds/PipelineBuildFacadeService.kt @@ -110,6 +110,7 @@ import com.tencent.devops.process.pojo.BuildManualStartupInfo import com.tencent.devops.process.pojo.ReviewParam import com.tencent.devops.process.pojo.StageQualityRequest import com.tencent.devops.process.pojo.VmInfo +import com.tencent.devops.process.pojo.pipeline.BuildRecordInfo import com.tencent.devops.process.pojo.pipeline.ModelDetail import com.tencent.devops.process.pojo.pipeline.ModelRecord import com.tencent.devops.process.pojo.pipeline.PipelineLatestBuild @@ -1462,6 +1463,32 @@ class PipelineBuildFacadeService( ) } + fun getBuildRecordInfo( + userId: String, + projectId: String, + pipelineId: String, + buildId: String, + channelCode: ChannelCode, + checkPermission: Boolean = true + ): List { + + if (checkPermission) { + pipelinePermissionService.validPipelinePermission( + userId = userId, + projectId = projectId, + pipelineId = pipelineId, + permission = AuthPermission.VIEW, + message = null + ) + } + + return buildRecordService.getRecordInfo( + projectId = projectId, + pipelineId = pipelineId, + buildId = buildId + ) + } + fun goToLatestFinishedBuild( userId: String, projectId: String, From c4ec5d896a5b407269583085e8a55d79998dc237 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Fri, 24 Nov 2023 15:45:51 +0800 Subject: [PATCH 07/25] =?UTF-8?q?feat:=20=E8=80=97=E6=97=B6=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=BC=98=E5=8C=96=20#9505=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/log/resources/ServiceLogPrintResourceImpl.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/ServiceLogPrintResourceImpl.kt b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/ServiceLogPrintResourceImpl.kt index 83154d4e442..4b4d84d3c17 100644 --- a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/ServiceLogPrintResourceImpl.kt +++ b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/resources/ServiceLogPrintResourceImpl.kt @@ -76,7 +76,7 @@ class ServiceLogPrintResourceImpl @Autowired constructor( // #7168 通过一次获取创建记录以及缓存 val index = indexService.getIndexName(buildId) logger.info("Start to print log to index[$index]") - buildLogPrintService.dispatchEvent( + buildLogPrintService.asyncDispatchEvent( LogStatusEvent( buildId = buildId, finished = false, @@ -102,7 +102,7 @@ class ServiceLogPrintResourceImpl @Autowired constructor( logger.warn("Invalid build ID[$buildId]") return Result(false) } - buildLogPrintService.dispatchEvent( + buildLogPrintService.asyncDispatchEvent( LogStatusEvent( buildId = buildId, finished = finished, From 653c34b840da18929ffae5fcb0b58ea809375f0b Mon Sep 17 00:00:00 2001 From: royalhuang Date: Mon, 27 Nov 2023 11:20:35 +0800 Subject: [PATCH 08/25] =?UTF-8?q?feat:=20=E8=80=97=E6=97=B6=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=BC=98=E5=8C=96=20#9505=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../log/service/impl/LogServiceESImpl.kt | 25 +++++++++++++++---- .../engine/service/PipelineRuntimeService.kt | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/impl/LogServiceESImpl.kt b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/impl/LogServiceESImpl.kt index 87ddc454348..ee5f8187f52 100644 --- a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/impl/LogServiceESImpl.kt +++ b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/impl/LogServiceESImpl.kt @@ -489,8 +489,11 @@ class LogServiceESImpl( if (exString.contains("index_closed_exception")) { logger.warn("[$buildId] Can't search because of index_closed_exception", e) queryLogs.status = LogStatus.CLOSED.status + } else if (exString.contains("Too Many Requests")) { + logger.warn("[$buildId] Too many query requests", e) + queryLogs.status = LogStatus.FAIL.status } - } catch (ignore: Exception) { + } catch (ignore: Throwable) { logger.warn("Query init logs failed because of ${ignore.javaClass}. buildId: $buildId", ignore) queryLogs.status = LogStatus.FAIL.status } @@ -640,8 +643,11 @@ class LogServiceESImpl( if (exString.contains("index_closed_exception")) { logger.warn("[$buildId] Can't search because of index_closed_exception", e) queryLogs.status = LogStatus.CLOSED.status + } else if (exString.contains("Too Many Requests")) { + logger.warn("[$buildId] Too many query requests", e) + queryLogs.status = LogStatus.FAIL.status } - } catch (ignore: Exception) { + } catch (ignore: Throwable) { logger.warn("Query end logs failed because of ${ignore.javaClass}. buildId: $buildId", ignore) queryLogs.status = LogStatus.FAIL.status } @@ -707,8 +713,11 @@ class LogServiceESImpl( if (exString.contains("index_closed_exception")) { logger.warn("[$buildId] Can't search because of index_closed_exception", e) queryLogs.status = LogStatus.CLOSED.status + } else if (exString.contains("Too Many Requests")) { + logger.warn("[$buildId] Too many query requests", e) + queryLogs.status = LogStatus.FAIL.status } - } catch (ignore: Exception) { + } catch (ignore: Throwable) { logger.warn("Query init logs failed because of ${ignore.javaClass}. buildId: $buildId", ignore) queryLogs.status = LogStatus.FAIL.status } @@ -799,8 +808,11 @@ class LogServiceESImpl( if (exString.contains("index_closed_exception")) { logger.warn("[$buildId] Can't search because of index_closed_exception", e) queryLogs.status = LogStatus.CLOSED.status + } else if (exString.contains("Too Many Requests")) { + logger.warn("[$buildId] Too many query requests", e) + queryLogs.status = LogStatus.FAIL.status } - } catch (ignore: Exception) { + } catch (ignore: Throwable) { logger.warn("Query after logs failed because of ${ignore.javaClass}. buildId: $buildId", ignore) queryLogs.status = LogStatus.FAIL.status queryLogs.finished = true @@ -883,8 +895,11 @@ class LogServiceESImpl( if (exString.contains("index_closed_exception")) { logger.warn("[$buildId] Can't search because of index_closed_exception", e) queryLogs.status = LogStatus.CLOSED.status + } else if (exString.contains("Too Many Requests")) { + logger.warn("[$buildId] Too many query requests", e) + queryLogs.status = LogStatus.FAIL.status } - } catch (ignore: Exception) { + } catch (ignore: Throwable) { logger.warn("Query before logs failed because of ${ignore.javaClass}. buildId: $buildId", ignore) queryLogs.status = LogStatus.FAIL.status queryLogs.finished = true diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRuntimeService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRuntimeService.kt index a796be96b3c..c4c44f3562c 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRuntimeService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRuntimeService.kt @@ -1605,7 +1605,7 @@ class PipelineRuntimeService @Autowired constructor( } with(latestRunningBuild) { val executeTime = try { - timeCost?.executeCost ?: getExecuteTime(latestRunningBuild.projectId, buildId) + timeCost?.totalCost ?: getExecuteTime(latestRunningBuild.projectId, buildId) } catch (ignored: Throwable) { logger.warn("[$pipelineId]|getExecuteTime-$buildId exception:", ignored) 0L From d997dffffc6983c126153dc64314fbc2d83a08aa Mon Sep 17 00:00:00 2001 From: mingshewhe Date: Wed, 29 Nov 2023 18:10:44 +0800 Subject: [PATCH 09/25] =?UTF-8?q?feat=EF=BC=9A=E5=AD=90=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E7=BA=BF=E8=B0=83=E7=94=A8=E8=A7=A6=E5=8F=91=E7=9A=84=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=EF=BC=8C=E8=A7=A6=E5=8F=91=E6=9D=90=E6=96=99=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=88=B6=E6=B5=81=E6=B0=B4=E7=BA=BF=20#8682?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tencent/devops/process/service/SubPipelineStartUpService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/SubPipelineStartUpService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/SubPipelineStartUpService.kt index 36d657ae5eb..b3e6550bfad 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/SubPipelineStartUpService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/SubPipelineStartUpService.kt @@ -224,7 +224,7 @@ class SubPipelineStartUpService @Autowired constructor( ) val parentBuildInfo = pipelineRuntimeService.getBuildInfo( - projectId = projectId, + projectId = parentProjectId, buildId = parentBuildId ) ?: throw ErrorCodeException( statusCode = Response.Status.NOT_FOUND.statusCode, From 37ae1d0dfed62372a04fc79f2184b3460f5598ce Mon Sep 17 00:00:00 2001 From: royalhuang Date: Thu, 30 Nov 2023 15:18:08 +0800 Subject: [PATCH 10/25] =?UTF-8?q?feat:=20=E8=80=97=E6=97=B6=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=BC=98=E5=8C=96=20#9505=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/dao/template/TemplateDao.kt | 6 ++--- .../template/service/TemplateService.kt | 8 ++++++- .../template/TemplateInstanceCronService.kt | 3 +++ .../service/template/TemplateFacadeService.kt | 22 ++++++++++++++++++- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/template/TemplateDao.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/template/TemplateDao.kt index 1d1364fa333..945e7a1f3dc 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/template/TemplateDao.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/template/TemplateDao.kt @@ -295,7 +295,7 @@ class TemplateDao { dslContext: DSLContext, projectId: String? = null, version: Long - ): TTemplateRecord { + ): TTemplateRecord? { with(TTemplate.T_TEMPLATE) { val conditions = mutableListOf() conditions.add(VERSION.eq(version)) @@ -305,9 +305,7 @@ class TemplateDao { return dslContext.selectFrom(this) .where(conditions) .limit(1) - .fetchOne() ?: throw ErrorCodeException( - errorCode = ProcessMessageCode.ERROR_TEMPLATE_NOT_EXISTS - ) + .fetchOne() } } diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/template/service/TemplateService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/template/service/TemplateService.kt index 73ee1848e81..b34bc2fc29c 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/template/service/TemplateService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/template/service/TemplateService.kt @@ -27,9 +27,11 @@ package com.tencent.devops.process.template.service +import com.tencent.devops.common.api.exception.ErrorCodeException import com.tencent.devops.common.api.util.JsonUtil import com.tencent.devops.common.pipeline.pojo.BuildFormProperty import com.tencent.devops.common.pipeline.pojo.BuildNo +import com.tencent.devops.process.constant.ProcessMessageCode import com.tencent.devops.process.engine.dao.template.TemplateDao import com.tencent.devops.process.engine.dao.template.TemplatePipelineDao import org.jooq.DSLContext @@ -83,7 +85,11 @@ class TemplateService @Autowired constructor( when { fixTemplateVersion != null -> { // 否则以指定的版本 templateVersion = fixTemplateVersion - versionName = templateDao.getTemplate(dslContext = dslContext, version = fixTemplateVersion).versionName + val template = templateDao.getTemplate(dslContext = dslContext, version = fixTemplateVersion) + ?: throw ErrorCodeException( + errorCode = ProcessMessageCode.ERROR_TEMPLATE_NOT_EXISTS + ) + versionName = template.versionName } else -> { // 以指定的模板Id创建 templateVersion = latestTemplate.version diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/template/TemplateInstanceCronService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/template/TemplateInstanceCronService.kt index 573e681183b..0212ad738c9 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/template/TemplateInstanceCronService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/template/TemplateInstanceCronService.kt @@ -143,6 +143,9 @@ class TemplateInstanceCronService @Autowired constructor( val template: TTemplateRecord? try { template = templateDao.getTemplate(dslContext = dslContext, version = templateVersion) + ?: throw ErrorCodeException( + errorCode = ProcessMessageCode.ERROR_TEMPLATE_NOT_EXISTS + ) } catch (e: ErrorCodeException) { if (e.errorCode == ProcessMessageCode.ERROR_TEMPLATE_NOT_EXISTS) { // 模板版本记录如果已经被删,则无需执行更新任务并把任务记录删除 diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/template/TemplateFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/template/TemplateFacadeService.kt index 4041c716819..418a478ed9a 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/template/TemplateFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/template/TemplateFacadeService.kt @@ -1047,6 +1047,9 @@ class TemplateFacadeService @Autowired constructor( ) } else { templateDao.getTemplate(dslContext = dslContext, version = version) + ?: throw ErrorCodeException( + errorCode = ERROR_TEMPLATE_NOT_EXISTS + ) } } val currentVersion = TemplateVersion( @@ -1149,8 +1152,12 @@ class TemplateFacadeService @Autowired constructor( language = I18nUtil.getLanguage(userId) ) ) + val templateRecord = templateDao.getTemplate(dslContext = dslContext, version = templatePipelineRecord.version) + ?: throw ErrorCodeException( + errorCode = ERROR_TEMPLATE_NOT_EXISTS + ) val template: Model = objectMapper.readValue( - templateDao.getTemplate(dslContext = dslContext, version = templatePipelineRecord.version).template + templateRecord.template ) val v1Model: Model = instanceCompareModel( objectMapper.readValue( @@ -1164,6 +1171,9 @@ class TemplateFacadeService @Autowired constructor( ) val srcTemplate = templateDao.getTemplate(dslContext = dslContext, version = version) + ?: throw ErrorCodeException( + errorCode = ERROR_TEMPLATE_NOT_EXISTS + ) val v2Model = getTemplateModel(srcTemplate.template) val v1Containers = getContainers(v1Model) val v2Containers = getContainers(v2Model) @@ -1284,6 +1294,9 @@ class TemplateFacadeService @Autowired constructor( ): Map { try { val template = templateDao.getTemplate(dslContext = dslContext, version = version) + ?: throw ErrorCodeException( + errorCode = ERROR_TEMPLATE_NOT_EXISTS + ) val templateModel: Model = objectMapper.readValue(template.template) val templateTriggerContainer = templateModel.stages[0].containers[0] as TriggerContainer val latestInstances = listLatestModel(projectId, pipelineIds) @@ -1340,6 +1353,9 @@ class TemplateFacadeService @Autowired constructor( ): TemplateOperationRet { logger.info("Create the new template instance [$projectId|$userId|$templateId|$version|$useTemplateSettings]") val template = templateDao.getTemplate(dslContext = dslContext, version = version) + ?: throw ErrorCodeException( + errorCode = ERROR_TEMPLATE_NOT_EXISTS + ) val successPipelines = ArrayList() val failurePipelines = ArrayList() val successPipelinesId = ArrayList() @@ -1621,6 +1637,10 @@ class TemplateFacadeService @Autowired constructor( // 当更新的实例数量较小则走同步更新逻辑,较大走异步更新逻辑 if (instances.size <= maxSyncInstanceNum) { val template = templateDao.getTemplate(dslContext = dslContext, version = version) + ?: throw ErrorCodeException( + errorCode = ERROR_TEMPLATE_NOT_EXISTS + ) + val successPipelines = ArrayList() val failurePipelines = ArrayList() instances.forEach { templateInstanceUpdate -> From 9b47e42c727a95681659fc00ddb1a95aafe97876 Mon Sep 17 00:00:00 2001 From: royalhuang Date: Thu, 30 Nov 2023 15:26:40 +0800 Subject: [PATCH 11/25] =?UTF-8?q?feat:=20=E8=80=97=E6=97=B6=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=BC=98=E5=8C=96=20#9505=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/engine/dao/template/TemplateDao.kt | 6 ++---- .../process/engine/service/PipelineRepositoryService.kt | 2 +- .../process/service/template/TemplateFacadeService.kt | 9 +++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/template/TemplateDao.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/template/TemplateDao.kt index 945e7a1f3dc..d31b3bfca4e 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/template/TemplateDao.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/template/TemplateDao.kt @@ -314,7 +314,7 @@ class TemplateDao { templateId: String, versionName: String? = null, version: Long? = null - ): TTemplateRecord { + ): TTemplateRecord? { with(TTemplate.T_TEMPLATE) { val conditions = mutableListOf() conditions.add(ID.eq(templateId)) @@ -328,9 +328,7 @@ class TemplateDao { .where(conditions) .orderBy(CREATED_TIME.desc(), VERSION.desc()) .limit(1) - .fetchOne() ?: throw ErrorCodeException( - errorCode = ProcessMessageCode.ERROR_TEMPLATE_NOT_EXISTS - ) + .fetchOne() } } diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt index 6c7e59463d8..79c3ecdafdd 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt @@ -763,7 +763,7 @@ class PipelineRepositoryService constructor( val template = templatePipelineDao.get(dslContext, projectId, pipelineId) val srcTemplate = template?.let { t -> templateDao.getTemplate( - dslContext = dslContext, version = t.version) + dslContext = dslContext, templateId = t.templateId) } val templateId = template?.templateId val info = pipelineInfoDao.convert( diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/template/TemplateFacadeService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/template/TemplateFacadeService.kt index 418a478ed9a..8b5612ba6f0 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/template/TemplateFacadeService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/template/TemplateFacadeService.kt @@ -1047,10 +1047,9 @@ class TemplateFacadeService @Autowired constructor( ) } else { templateDao.getTemplate(dslContext = dslContext, version = version) - ?: throw ErrorCodeException( - errorCode = ERROR_TEMPLATE_NOT_EXISTS - ) - } + } ?: throw ErrorCodeException( + errorCode = ERROR_TEMPLATE_NOT_EXISTS + ) } val currentVersion = TemplateVersion( template.version, @@ -1489,6 +1488,8 @@ class TemplateFacadeService @Autowired constructor( templateId = srcTemplateId ?: templateId, versionName = versionName, version = version + ) ?: throw ErrorCodeException( + errorCode = ERROR_TEMPLATE_NOT_EXISTS ) instances.forEach { try { From bf8a2760b9475b7ac2c397a66126eec255ac1683 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 30 Nov 2023 10:43:26 +0800 Subject: [PATCH 12/25] =?UTF-8?q?=E3=80=90PAC=E3=80=91feat=EF=BC=9A?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BB=A3=E7=A0=81=E5=BA=93=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=20#8118?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/api/UserRepositoryResource.kt | 3 ++ .../pojo/RepositoryInfoWithPermission.kt | 2 + .../repository/dao/RepoPipelineRefDao.kt | 42 +++++++++++-------- .../resources/UserRepositoryResourceImpl.kt | 2 + .../repository/service/RepoPipelineService.kt | 3 ++ .../repository/service/RepositoryService.kt | 11 ++++- 6 files changed, 44 insertions(+), 19 deletions(-) diff --git a/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/api/UserRepositoryResource.kt b/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/api/UserRepositoryResource.kt index e9b17c4d5dc..47d815b88bb 100644 --- a/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/api/UserRepositoryResource.kt +++ b/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/api/UserRepositoryResource.kt @@ -290,6 +290,9 @@ interface UserRepositoryResource { @ApiParam("代码库哈希ID", required = true) @PathParam("repositoryHashId") repositoryHashId: String, + @ApiParam("事件类型", required = false) + @QueryParam("eventType") + eventType: String?, @ApiParam("触发条件MD5", required = false) @QueryParam("triggerConditionMd5") triggerConditionMd5: String?, diff --git a/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/pojo/RepositoryInfoWithPermission.kt b/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/pojo/RepositoryInfoWithPermission.kt index ba5a765dd37..2828e39cf24 100644 --- a/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/pojo/RepositoryInfoWithPermission.kt +++ b/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/pojo/RepositoryInfoWithPermission.kt @@ -53,6 +53,8 @@ data class RepositoryInfoWithPermission( val canEdit: Boolean, @ApiModelProperty("能否被删除", required = true) val canDelete: Boolean, + @ApiModelProperty("能否被查看", required = true) + val canView: Boolean? = null, @ApiModelProperty("能否被使用", required = true) val canUse: Boolean? = null, @ApiModelProperty("认证类型", required = false) diff --git a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/dao/RepoPipelineRefDao.kt b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/dao/RepoPipelineRefDao.kt index 511672d24be..66419acb38b 100644 --- a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/dao/RepoPipelineRefDao.kt +++ b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/dao/RepoPipelineRefDao.kt @@ -139,22 +139,25 @@ class RepoPipelineRefDao { dslContext: DSLContext, projectId: String, repositoryId: Long, + eventType: String?, triggerConditionMd5: String?, limit: Int, offset: Int ): List { return with(TRepositoryPipelineRef.T_REPOSITORY_PIPELINE_REF) { + val conditions = mutableListOf( + PROJECT_ID.eq(projectId), + REPOSITORY_ID.eq(repositoryId) + ) + if (!triggerConditionMd5.isNullOrBlank()) { + conditions.add(TRIGGER_CONDITION_MD5.eq(triggerConditionMd5)) + } + if (!eventType.isNullOrBlank()) { + conditions.add(EVENT_TYPE.eq(eventType)) + } dslContext.select(PROJECT_ID, PIPELINE_ID, PIPELINE_NAME) .from(this) - .where(PROJECT_ID.eq(projectId)) - .and(REPOSITORY_ID.eq(repositoryId)) - .let { - if (triggerConditionMd5.isNullOrBlank()) { - it - } else { - it.and(TRIGGER_CONDITION_MD5.eq(triggerConditionMd5)) - } - } + .where(conditions) .groupBy(PROJECT_ID, PIPELINE_ID, PIPELINE_NAME) .orderBy(PIPELINE_NAME.desc()) .limit(limit).offset(offset) @@ -172,20 +175,23 @@ class RepoPipelineRefDao { dslContext: DSLContext, projectId: String, repositoryId: Long, + eventType: String?, triggerConditionMd5: String? ): Long { return with(TRepositoryPipelineRef.T_REPOSITORY_PIPELINE_REF) { + val conditions = mutableListOf( + PROJECT_ID.eq(projectId), + REPOSITORY_ID.eq(repositoryId) + ) + if (!triggerConditionMd5.isNullOrBlank()) { + conditions.add(TRIGGER_CONDITION_MD5.eq(triggerConditionMd5)) + } + if (!eventType.isNullOrBlank()) { + conditions.add(EVENT_TYPE.eq(eventType)) + } dslContext.select() .from(this) - .where(PROJECT_ID.eq(projectId)) - .and(REPOSITORY_ID.eq(repositoryId)) - .let { - if (triggerConditionMd5.isNullOrBlank()) { - it - } else { - it.and(TRIGGER_CONDITION_MD5.eq(triggerConditionMd5)) - } - } + .where(conditions) .groupBy(PROJECT_ID, PIPELINE_ID, PIPELINE_NAME) .fetchGroups(PIPELINE_ID).size.toLong() } diff --git a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/resources/UserRepositoryResourceImpl.kt b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/resources/UserRepositoryResourceImpl.kt index 4585f95cdc5..35442540411 100644 --- a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/resources/UserRepositoryResourceImpl.kt +++ b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/resources/UserRepositoryResourceImpl.kt @@ -302,6 +302,7 @@ class UserRepositoryResourceImpl @Autowired constructor( userId: String, projectId: String, repositoryHashId: String, + eventType: String?, triggerConditionMd5: String?, page: Int?, pageSize: Int? @@ -313,6 +314,7 @@ class UserRepositoryResourceImpl @Autowired constructor( repoPipelineService.listPipelineRef( projectId = projectId, repositoryHashId = repositoryHashId, + eventType = eventType, triggerConditionMd5 = triggerConditionMd5, limit = limit.limit, offset = limit.offset diff --git a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoPipelineService.kt b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoPipelineService.kt index 52841bd452a..a83f1bd33ce 100644 --- a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoPipelineService.kt +++ b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoPipelineService.kt @@ -176,6 +176,7 @@ class RepoPipelineService @Autowired constructor( fun listPipelineRef( projectId: String, repositoryHashId: String, + eventType: String?, triggerConditionMd5: String?, limit: Int, offset: Int @@ -185,12 +186,14 @@ class RepoPipelineService @Autowired constructor( dslContext = dslContext, projectId = projectId, repositoryId = repositoryId, + eventType = eventType, triggerConditionMd5 = triggerConditionMd5 ) val records = repoPipelineRefDao.listByRepo( dslContext = dslContext, projectId = projectId, repositoryId = repositoryId, + eventType = eventType, triggerConditionMd5 = triggerConditionMd5, limit = limit, offset = offset diff --git a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepositoryService.kt b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepositoryService.kt index a61a7cebdde..5879235143e 100644 --- a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepositoryService.kt +++ b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepositoryService.kt @@ -665,12 +665,19 @@ class RepositoryService @Autowired constructor( val permissionToListMap = repositoryPermissionService.filterRepositories( userId = userId, projectId = projectId, - authPermissions = setOf(AuthPermission.LIST, AuthPermission.EDIT, AuthPermission.DELETE, AuthPermission.USE) + authPermissions = setOf( + AuthPermission.LIST, + AuthPermission.EDIT, + AuthPermission.DELETE, + AuthPermission.USE, + AuthPermission.VIEW + ) ) val hasListPermissionRepoList = permissionToListMap[AuthPermission.LIST]!! val hasEditPermissionRepoList = permissionToListMap[AuthPermission.EDIT]!! val hasDeletePermissionRepoList = permissionToListMap[AuthPermission.DELETE]!! val hasUsePermissionRepoList = permissionToListMap[AuthPermission.USE]!! + val hasViewPermissionRepoList = permissionToListMap[AuthPermission.VIEW]!! val count = repositoryDao.countByProject( dslContext = dslContext, @@ -704,6 +711,7 @@ class RepositoryService @Autowired constructor( val hasEditPermission = hasEditPermissionRepoList.contains(it.repositoryId) val hasDeletePermission = hasDeletePermissionRepoList.contains(it.repositoryId) val hasUsePermission = hasUsePermissionRepoList.contains(it.repositoryId) + val hasViewPermission = hasViewPermissionRepoList.contains(it.repositoryId) val authInfo = repoAuthInfoMap[it.repositoryId] RepositoryInfoWithPermission( repositoryHashId = HashUtil.encodeOtherLongId(it.repositoryId), @@ -714,6 +722,7 @@ class RepositoryService @Autowired constructor( canEdit = hasEditPermission, canDelete = hasDeletePermission, canUse = hasUsePermission, + canView = hasViewPermission, authType = authInfo?.authType ?: RepoAuthType.HTTP.name, svnType = authInfo?.svnType, authIdentity = authInfo?.credentialId?.ifBlank { it.userId }, From 43a1c9647fb60dc9b3f9e806062bc2d6022ccd70 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 30 Nov 2023 16:25:38 +0800 Subject: [PATCH 13/25] =?UTF-8?q?=E3=80=90PAC=E3=80=91feat=EF=BC=9A?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BB=A3=E7=A0=81=E5=BA=93=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=20#8118?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CodeGithubWebHookTriggerElement.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/trigger/CodeGithubWebHookTriggerElement.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/trigger/CodeGithubWebHookTriggerElement.kt index c613ce32386..5921b0003c9 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/trigger/CodeGithubWebHookTriggerElement.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/trigger/CodeGithubWebHookTriggerElement.kt @@ -91,6 +91,25 @@ data class CodeGithubWebHookTriggerElement( ) } + CodeEventType.REVIEW -> { + listOf( + TriggerElementPropUtils.selector(name = "includeCrState", value = includeCrState), + ) + } + + CodeEventType.ISSUES -> { + listOf( + TriggerElementPropUtils.selector(name = "includeIssueAction", value = includeIssueAction) + ) + } + + CodeEventType.NOTE -> { + listOf( + TriggerElementPropUtils.selector(name = "includeNoteTypes", value = includeNoteTypes), + TriggerElementPropUtils.vuexInput(name = "includeNoteComment", value = includeNoteComment) + ) + } + else -> emptyList() } return props.filterNotNull() From fa8b66356ab8cf37658383433263d4cae7491d35 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 30 Nov 2023 16:39:35 +0800 Subject: [PATCH 14/25] =?UTF-8?q?=E3=80=90PAC=E3=80=91feat=EF=BC=9A?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BB=A3=E7=A0=81=E5=BA=93=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=20#8118?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pojo/element/trigger/CodeGithubWebHookTriggerElement.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/trigger/CodeGithubWebHookTriggerElement.kt b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/trigger/CodeGithubWebHookTriggerElement.kt index 5921b0003c9..c3a5277e409 100644 --- a/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/trigger/CodeGithubWebHookTriggerElement.kt +++ b/src/backend/ci/core/common/common-pipeline/src/main/kotlin/com/tencent/devops/common/pipeline/pojo/element/trigger/CodeGithubWebHookTriggerElement.kt @@ -93,7 +93,7 @@ data class CodeGithubWebHookTriggerElement( CodeEventType.REVIEW -> { listOf( - TriggerElementPropUtils.selector(name = "includeCrState", value = includeCrState), + TriggerElementPropUtils.selector(name = "includeCrState", value = includeCrState) ) } From e216b4b52b9fa9fcd86e87260da2eabb28371946 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 30 Nov 2023 17:07:52 +0800 Subject: [PATCH 15/25] =?UTF-8?q?=E3=80=90PAC=E3=80=91feat=EF=BC=9A?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BB=A3=E7=A0=81=E5=BA=93=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=20#8118?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/repository/pojo/RepoTriggerRefVo.kt | 6 ++++-- .../devops/repository/service/RepoPipelineService.kt | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/pojo/RepoTriggerRefVo.kt b/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/pojo/RepoTriggerRefVo.kt index 6ffa46688d7..4b5e3c2d878 100644 --- a/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/pojo/RepoTriggerRefVo.kt +++ b/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/pojo/RepoTriggerRefVo.kt @@ -38,7 +38,7 @@ data class RepoTriggerRefVo( val atomCode: String, @ApiModelProperty("触发类型") val triggerType: String, - @ApiModelProperty("事件类型") + @ApiModelProperty("事件类型,根据[eventTypeKey]进行国际化") val eventType: String, @ApiModelProperty("插件参数") val taskParams: Map, @@ -48,5 +48,7 @@ data class RepoTriggerRefVo( val triggerConditionMd5: String?, @ApiModelProperty("流水线引用数量") val pipelineRefCount: Int, - val atomLogo: String? = null + val atomLogo: String? = null, + @ApiModelProperty("事件类型key") + val eventTypeKey: String ) diff --git a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoPipelineService.kt b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoPipelineService.kt index a83f1bd33ce..42836d8b83a 100644 --- a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoPipelineService.kt +++ b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoPipelineService.kt @@ -249,7 +249,8 @@ class RepoPipelineService @Autowired constructor( pipelineRefCount = pipelineRefCountMap[it.id] ?: 0, atomLogo = atomProps?.run { this[it.atomCode]?.logoUrl ?: "" - } + }, + eventTypeKey = it.eventType ) } return SQLPage(count = count, records = triggerRecords) From 88d48bab5c384ea5ce6e615473e8ec9cefa0d8be Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Thu, 30 Nov 2023 17:18:29 +0800 Subject: [PATCH 16/25] =?UTF-8?q?=E3=80=90PAC=E3=80=91feat=EF=BC=9A?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BB=A3=E7=A0=81=E5=BA=93=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=20#8118?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/repository/pojo/RepoTriggerRefVo.kt | 6 +++--- .../devops/repository/service/RepoPipelineService.kt | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/pojo/RepoTriggerRefVo.kt b/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/pojo/RepoTriggerRefVo.kt index 4b5e3c2d878..ac44777c0ea 100644 --- a/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/pojo/RepoTriggerRefVo.kt +++ b/src/backend/ci/core/repository/api-repository/src/main/kotlin/com/tencent/devops/repository/pojo/RepoTriggerRefVo.kt @@ -38,8 +38,8 @@ data class RepoTriggerRefVo( val atomCode: String, @ApiModelProperty("触发类型") val triggerType: String, - @ApiModelProperty("事件类型,根据[eventTypeKey]进行国际化") - val eventType: String, + @ApiModelProperty("事件类型描述,根据[eventType]进行国际化") + val eventTypeDesc: String, @ApiModelProperty("插件参数") val taskParams: Map, @ApiModelProperty("触发条件") @@ -50,5 +50,5 @@ data class RepoTriggerRefVo( val pipelineRefCount: Int, val atomLogo: String? = null, @ApiModelProperty("事件类型key") - val eventTypeKey: String + val eventType: String ) diff --git a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoPipelineService.kt b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoPipelineService.kt index 42836d8b83a..befcb42d22a 100644 --- a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoPipelineService.kt +++ b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoPipelineService.kt @@ -237,7 +237,7 @@ class RepoPipelineService @Autowired constructor( repositoryHashId = HashUtil.encodeOtherLongId(it.repositoryId), atomCode = it.atomCode, triggerType = it.triggerType, - eventType = I18nUtil.getCodeLanMessage( + eventTypeDesc = I18nUtil.getCodeLanMessage( messageCode = "${CodeEventType.MESSAGE_CODE_PREFIX}_${it.eventType}", defaultMessage = it.eventType ), @@ -250,7 +250,7 @@ class RepoPipelineService @Autowired constructor( atomLogo = atomProps?.run { this[it.atomCode]?.logoUrl ?: "" }, - eventTypeKey = it.eventType + eventType = it.eventType ) } return SQLPage(count = count, records = triggerRecords) From b1c53db117647a12c518ac7cd867b1254ffccc2e Mon Sep 17 00:00:00 2001 From: royalhuang Date: Thu, 30 Nov 2023 19:34:27 +0800 Subject: [PATCH 17/25] =?UTF-8?q?feat:=20=E8=80=97=E6=97=B6=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=BC=98=E5=8C=96=20#9505?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/service/PipelineRepositoryService.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt index 79c3ecdafdd..a801c884ce0 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt @@ -758,9 +758,10 @@ class PipelineRepositoryService constructor( projectId: String, pipelineId: String, channelCode: ChannelCode? = null, - delete: Boolean? = false + delete: Boolean? = false, + queryDslContext: DSLContext? = null ): PipelineInfo? { - val template = templatePipelineDao.get(dslContext, projectId, pipelineId) + val template = templatePipelineDao.get(queryDslContext ?: dslContext, projectId, pipelineId) val srcTemplate = template?.let { t -> templateDao.getTemplate( dslContext = dslContext, templateId = t.templateId) @@ -768,7 +769,7 @@ class PipelineRepositoryService constructor( val templateId = template?.templateId val info = pipelineInfoDao.convert( t = pipelineInfoDao.getPipelineInfo( - dslContext = dslContext, + dslContext = queryDslContext ?: dslContext, projectId = projectId, pipelineId = pipelineId, channelCode = channelCode, @@ -778,10 +779,10 @@ class PipelineRepositoryService constructor( ) if (info != null && srcTemplate != null) { info.templateInfo = TemplateInfo( - templateId = srcTemplate.id, + templateId = template.templateId, templateName = srcTemplate.templateName, - version = srcTemplate.version, - versionName = srcTemplate.versionName, + version = template.version, + versionName = template.versionName, instanceType = PipelineInstanceTypeEnum.valueOf(template.instanceType) ) } From 63303828d23922e7fccdc77a84e8cd72304dea4d Mon Sep 17 00:00:00 2001 From: mingshewhe Date: Thu, 30 Nov 2023 19:52:50 +0800 Subject: [PATCH 18/25] =?UTF-8?q?=E3=80=90PAC=E3=80=91feat=EF=BC=9A?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=8E=E4=BB=A3=E7=A0=81=E5=BA=93=E7=BB=B4?= =?UTF-8?q?=E5=BA=A6=E6=9F=A5=E7=9C=8B=E5=AF=B9=E5=BA=94=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=BA=93=E4=BA=8B=E4=BB=B6=20#8122?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/pojo/webhook/PipelineWebhook.kt | 6 ++- .../process/engine/dao/PipelineWebhookDao.kt | 44 ++++--------------- .../engine/service/PipelineWebhookService.kt | 25 +++-------- .../service/PipelineWebhookUpgradeService.kt | 17 +++---- .../sql/1001_ci_process_ddl_mysql.sql | 1 + .../2020_ci_process-update_v2.0_mysql.sql | 8 ++++ 6 files changed, 33 insertions(+), 68 deletions(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/webhook/PipelineWebhook.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/webhook/PipelineWebhook.kt index 609b2d58ec9..f018dabdb68 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/webhook/PipelineWebhook.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/webhook/PipelineWebhook.kt @@ -56,6 +56,8 @@ data class PipelineWebhook( var eventType: String? = null, @ApiModelProperty("代码库hashId,插件配置解析后的代码库ID", required = false) var repositoryHashId: String? = null, - @ApiModelProperty("事件源外联Id", required = false) - var externalId: String? = null + @ApiModelProperty("代码库平台ID", required = false) + var externalId: String? = null, + @ApiModelProperty("代码库平台仓库名", required = false) + var externalName: String? = null ) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/PipelineWebhookDao.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/PipelineWebhookDao.kt index 9fa16efaf8e..656d9081691 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/PipelineWebhookDao.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/PipelineWebhookDao.kt @@ -58,7 +58,8 @@ class PipelineWebhookDao { TASK_ID, EVENT_TYPE, REPOSITORY_HASH_ID, - EXTERNAL_ID + EXTERNAL_ID, + EXTERNAL_NAME ) .values( projectId, @@ -71,7 +72,8 @@ class PipelineWebhookDao { taskId, eventType, repositoryHashId, - externalId + externalId, + externalName ) .onDuplicateKeyUpdate() .set(REPO_TYPE, repoType?.name) @@ -81,6 +83,7 @@ class PipelineWebhookDao { .set(EVENT_TYPE, eventType) .set(REPOSITORY_HASH_ID, repositoryHashId) .set(EXTERNAL_ID, externalId) + .set(EXTERNAL_NAME, externalName) .execute() } } @@ -158,12 +161,12 @@ class PipelineWebhookDao { fun getByProjectNameAndType( dslContext: DSLContext, - projectNames: List, + projectName: String, repositoryType: String ): List? { with(T_PIPELINE_WEBHOOK) { return dslContext.select(PROJECT_ID, PIPELINE_ID).from(this) - .where(PROJECT_NAME.`in`(projectNames)) + .where(PROJECT_NAME.eq(projectName)) .and(REPOSITORY_TYPE.eq(repositoryType)) .and(DELETE.eq(false)) .groupBy(PROJECT_ID, PIPELINE_ID) @@ -216,22 +219,6 @@ class PipelineWebhookDao { } } - fun listWebhookPipeline( - dslContext: DSLContext, - projectName: String, - repositoryType: String, - eventType: String - ): List? { - with(T_PIPELINE_WEBHOOK) { - return dslContext.selectFrom(this) - .where(PROJECT_NAME.eq(projectName)) - .and(REPOSITORY_TYPE.eq(repositoryType)) - .and(EVENT_TYPE.eq(eventType)) - .and(DELETE.eq(false)) - .fetch().map { convert(it) } - } - } - fun updateProjectNameAndTaskId( dslContext: DSLContext, projectId: String, @@ -330,6 +317,7 @@ class PipelineWebhookDao { repositoryHashId: String?, eventType: String, externalId: String?, + externalName: String?, pipelineId: String, projectId: String, taskId: String @@ -339,6 +327,7 @@ class PipelineWebhookDao { .set(REPOSITORY_HASH_ID, repositoryHashId) .set(EVENT_TYPE, eventType) .set(EXTERNAL_ID, externalId) + .set(EXTERNAL_NAME, externalName) .where(PROJECT_ID.eq(projectId)) .and(PIPELINE_ID.eq(pipelineId)) .and(TASK_ID.eq(taskId)) @@ -346,21 +335,6 @@ class PipelineWebhookDao { } } - fun updateProjectName( - dslContext: DSLContext, - projectId: String, - projectName: String, - id: Long - ) { - with(T_PIPELINE_WEBHOOK) { - dslContext.update(this) - .set(PROJECT_NAME, projectName) - .where(PROJECT_ID.eq(projectId)) - .and(ID.eq(id)) - .execute() - } - } - companion object { private val logger = LoggerFactory.getLogger(PipelineWebhookDao::class.java) } 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 403ce034084..1be6064f4ae 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 @@ -146,7 +146,7 @@ class PipelineWebhookService @Autowired constructor( repoHashId = repositoryConfig.repositoryHashId, repoName = repositoryConfig.repositoryName, taskId = element.id, - projectName = getProjectName(repositoryType = scmType.name, projectName = repository.projectName), + projectName = getProjectName(repository.projectName), repositoryHashId = repository.repoHashId, eventType = eventType?.name ?: "", externalId = repository.getExternalId() @@ -292,7 +292,7 @@ class PipelineWebhookService @Autowired constructor( fun getTriggerPipelines(name: String, repositoryType: String): List { return pipelineWebhookDao.getByProjectNameAndType( dslContext = dslContext, - projectNames = getTriggerProjectName(repositoryType = repositoryType, projectName = name), + projectName = getProjectName(name), repositoryType = repositoryType ) ?: emptyList() } @@ -310,26 +310,13 @@ class PipelineWebhookService @Autowired constructor( ) ?: emptyList() } - fun getProjectName(repositoryType: String, projectName: String): String { - val repoSplit = projectName.split("/") - // 如果代码库是svn类型,并且项目名是三层的,比如a/b/c,那对应的rep_name是b,工蜂svn webhook返回的rep_name结构 - if (repositoryType == ScmType.CODE_SVN.name && repoSplit.size == 3) { - return repoSplit[1].trim() - } - return projectName - } - - fun getTriggerProjectName(repositoryType: String, projectName: String): List { + fun getProjectName(projectName: String): String { + // 如果项目名是三层的,比如a/b/c,那对应的rep_name是b val repoSplit = projectName.split("/") if (repoSplit.size != 3) { - return listOf(projectName) - } - // 兼容历史数据,如果代码库类型是git,并且路径是三层,数据库只保留了第二层,导致查询的webhook数据量很大 - return if (repositoryType == ScmType.CODE_SVN.name) { - listOf(repoSplit[1].trim()) - } else { - listOf(repoSplit[1].trim(), projectName) + return projectName } + return repoSplit[1].trim() } fun listWebhook( 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 f36f0816869..bb533ed7efb 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 @@ -197,10 +197,7 @@ class PipelineWebhookUpgradeService( pipelineWebhookDao.updateProjectNameAndTaskId( dslContext = dslContext, projectId = projectId, - projectName = pipelineWebhookService.getProjectName( - repositoryType = repo.getScmType().name, - projectName = repo.projectName - ), + projectName = pipelineWebhookService.getProjectName(repo.projectName), taskId = element.id!!, id = id!! ) @@ -377,16 +374,11 @@ class PipelineWebhookUpgradeService( } val repository = getAndCacheRepo(projectId, webhookRepositoryConfig, repoCache) - // 历史原因,假如git的projectName有三个,如aaa/bbb/ccc,只读取了bbb,导致触发时获取的流水线数量很多,修复数据 + // 历史原因,假如git的projectName有三个,如aaa/bbb/ccc,只读取了bbb,导致触发时获取的流水线数量很多,记录日志 if (repository != null && webhook.projectName != repository.projectName) { logger.info( - "webhook projectName different from repo projectName|webhook:$webhook|repo:$repository" - ) - pipelineWebhookDao.updateProjectName( - dslContext = dslContext, - projectId = projectId, - projectName = repository.projectName, - id = webhook.id!! + "webhook projectName different from repo projectName|$projectId|$pipelineId|" + + "webhook:${webhook.projectName}|repo:${repository.projectName}" ) } val repositoryHashId = when { @@ -400,6 +392,7 @@ class PipelineWebhookUpgradeService( dslContext = dslContext, eventType = elementEventType?.name ?: "", externalId = repository?.getExternalId(), + externalName = repository?.projectName ?: webhook.projectName, projectId = projectId, pipelineId = pipelineId, taskId = webhook.taskId!!, diff --git a/support-files/sql/1001_ci_process_ddl_mysql.sql b/support-files/sql/1001_ci_process_ddl_mysql.sql index 1737a0f3c7f..c5f24d08601 100644 --- a/support-files/sql/1001_ci_process_ddl_mysql.sql +++ b/support-files/sql/1001_ci_process_ddl_mysql.sql @@ -643,6 +643,7 @@ CREATE TABLE IF NOT EXISTS `T_PIPELINE_WEBHOOK` ( `EVENT_TYPE` varchar(64) DEFAULT NULL COMMENT '事件类型', `EXTERNAL_ID` varchar(255) DEFAULT NULL COMMENT '代码库平台ID', `REPOSITORY_HASH_ID` varchar(64) null comment '代码库hashId', + `EXTERNAL_NAME` varchar(255) DEFAULT null COMMENT '代码库平台仓库名', PRIMARY KEY (`ID`), UNIQUE KEY `UNI_INX_TPW_PROJECT_PIPELINE_TASK` (`PROJECT_ID`, `PIPELINE_ID`,`TASK_ID`), KEY `IDX_PROJECT_NAME_REPOSITORY_TYPE` (`PROJECT_NAME`, `REPOSITORY_TYPE`) diff --git a/support-files/sql/2003_v2.x/2020_ci_process-update_v2.0_mysql.sql b/support-files/sql/2003_v2.x/2020_ci_process-update_v2.0_mysql.sql index 9e8b2a08b5e..167c1098e20 100644 --- a/support-files/sql/2003_v2.x/2020_ci_process-update_v2.0_mysql.sql +++ b/support-files/sql/2003_v2.x/2020_ci_process-update_v2.0_mysql.sql @@ -112,6 +112,14 @@ BEGIN ADD COLUMN `REPOSITORY_HASH_ID` varchar(64) null comment '代码库hashId'; END IF; + IF NOT EXISTS(SELECT 1 + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = db + AND TABLE_NAME = 'T_PIPELINE_WEBHOOK' + AND COLUMN_NAME = 'EXTERNAL_NAME') THEN + ALTER TABLE `T_PIPELINE_WEBHOOK` + ADD COLUMN `EXTERNAL_NAME` varchar(255) DEFAULT null COMMENT '代码库平台仓库名'; + END IF; COMMIT; END From 87f62a827806c20cc3a189de9c658f18d0fe574d Mon Sep 17 00:00:00 2001 From: royalhuang Date: Thu, 30 Nov 2023 19:57:45 +0800 Subject: [PATCH 19/25] =?UTF-8?q?feat:=20=E8=80=97=E6=97=B6=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E4=BC=98=E5=8C=96=20#9505?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/engine/service/PipelineRepositoryService.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt index a801c884ce0..72e252d9dd8 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/PipelineRepositoryService.kt @@ -758,10 +758,9 @@ class PipelineRepositoryService constructor( projectId: String, pipelineId: String, channelCode: ChannelCode? = null, - delete: Boolean? = false, - queryDslContext: DSLContext? = null + delete: Boolean? = false ): PipelineInfo? { - val template = templatePipelineDao.get(queryDslContext ?: dslContext, projectId, pipelineId) + val template = templatePipelineDao.get(dslContext, projectId, pipelineId) val srcTemplate = template?.let { t -> templateDao.getTemplate( dslContext = dslContext, templateId = t.templateId) @@ -769,7 +768,7 @@ class PipelineRepositoryService constructor( val templateId = template?.templateId val info = pipelineInfoDao.convert( t = pipelineInfoDao.getPipelineInfo( - dslContext = queryDslContext ?: dslContext, + dslContext = dslContext, projectId = projectId, pipelineId = pipelineId, channelCode = channelCode, From 298c5dd1cc2370d9a29b9927b5d0e59cdc834169 Mon Sep 17 00:00:00 2001 From: mingshewhe Date: Thu, 30 Nov 2023 20:14:34 +0800 Subject: [PATCH 20/25] =?UTF-8?q?=E3=80=90PAC=E3=80=91feat=EF=BC=9A?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=8E=E4=BB=A3=E7=A0=81=E5=BA=93=E7=BB=B4?= =?UTF-8?q?=E5=BA=A6=E6=9F=A5=E7=9C=8B=E5=AF=B9=E5=BA=94=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=BA=93=E4=BA=8B=E4=BB=B6=20#8122?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/api/op/OpScmWebhookResource.kt | 4 +--- .../devops/process/engine/dao/PipelineWebhookDao.kt | 8 -------- .../devops/process/api/op/OpScmWebhookResourceImpl.kt | 6 ++---- .../engine/service/PipelineWebhookUpgradeService.kt | 11 +++-------- 4 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/op/OpScmWebhookResource.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/op/OpScmWebhookResource.kt index 98d2ac16f22..321f46d29fe 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/op/OpScmWebhookResource.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/api/op/OpScmWebhookResource.kt @@ -37,8 +37,6 @@ interface OpScmWebhookResource { fun updateWebhookEventInfo( @ApiParam("待更新的项目ID", required = false) @QueryParam("projectId") - projectId: String?, - @ApiParam("待更新代码库平台项目名", required = false) - projectNames: List? + projectId: String? ): Result } diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/PipelineWebhookDao.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/PipelineWebhookDao.kt index 656d9081691..b1949fb2666 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/PipelineWebhookDao.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/dao/PipelineWebhookDao.kt @@ -280,7 +280,6 @@ class PipelineWebhookDao { fun groupPipelineList( dslContext: DSLContext, projectId: String?, - projectNames: List?, offset: Int, limit: Int ): List { @@ -294,13 +293,6 @@ class PipelineWebhookDao { it.and(PROJECT_ID.eq(projectId)) } } - .let { - if (projectNames.isNullOrEmpty()) { - it - } else { - it.and(PROJECT_NAME.`in`(projectNames)) - } - } .groupBy(PROJECT_ID, PIPELINE_ID) .limit(offset, limit) .fetch().map { diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/op/OpScmWebhookResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/op/OpScmWebhookResourceImpl.kt index afe2c42dc48..4e3f4abf1c4 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/op/OpScmWebhookResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/op/OpScmWebhookResourceImpl.kt @@ -21,12 +21,10 @@ class OpScmWebhookResourceImpl( } override fun updateWebhookEventInfo( - projectId: String?, - projectNames: List? + projectId: String? ): Result { pipelineWebhookUpgradeService.updateWebhookEventInfo( - projectId = projectId, - projectNames = projectNames + projectId = projectId ) return Result(true) } 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 bb533ed7efb..08922a6e3ef 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 @@ -283,15 +283,14 @@ class PipelineWebhookUpgradeService( } fun updateWebhookEventInfo( - projectId: String?, - projectNames: List? + projectId: String? ) { val startTime = System.currentTimeMillis() val threadPoolExecutor = Executors.newSingleThreadExecutor() threadPoolExecutor.submit { logger.info("PipelineWebhookService:begin updateWebhookEventInfo threadPoolExecutor") try { - updateWebhookEventInfoTask(projectId = projectId, projectNames = projectNames) + updateWebhookEventInfoTask(projectId = projectId) } catch (ignored: Exception) { logger.warn("PipelineWebhookService:updateWebhookEventInfo failed", ignored) } finally { @@ -301,10 +300,7 @@ class PipelineWebhookUpgradeService( } } - private fun updateWebhookEventInfoTask( - projectId: String?, - projectNames: List? - ) { + private fun updateWebhookEventInfoTask(projectId: String?) { var offset = 0 val limit = 1000 val repoCache = mutableMapOf>() @@ -314,7 +310,6 @@ class PipelineWebhookUpgradeService( val pipelines = pipelineWebhookDao.groupPipelineList( dslContext = dslContext, projectId = projectId, - projectNames = projectNames, limit = limit, offset = offset ) From b0793b00f1ea2067225ddeedf67e5e3f31469b89 Mon Sep 17 00:00:00 2001 From: mingshewhe Date: Thu, 30 Nov 2023 20:27:04 +0800 Subject: [PATCH 21/25] =?UTF-8?q?=E3=80=90PAC=E3=80=91feat=EF=BC=9A?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=8E=E4=BB=A3=E7=A0=81=E5=BA=93=E7=BB=B4?= =?UTF-8?q?=E5=BA=A6=E6=9F=A5=E7=9C=8B=E5=AF=B9=E5=BA=94=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=BA=93=E4=BA=8B=E4=BB=B6=20#8122?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/process/engine/service/PipelineWebhookService.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 1be6064f4ae..f0f1fd6041d 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 @@ -149,7 +149,8 @@ class PipelineWebhookService @Autowired constructor( projectName = getProjectName(repository.projectName), repositoryHashId = repository.repoHashId, eventType = eventType?.name ?: "", - externalId = repository.getExternalId() + externalId = repository.getExternalId(), + externalName = repository.projectName ) pipelineWebhookDao.save( dslContext = dslContext, From 5b31b3cf6c4c2f62bb6ecb675ab795d72b5f1fce Mon Sep 17 00:00:00 2001 From: mingshewhe Date: Thu, 30 Nov 2023 21:58:25 +0800 Subject: [PATCH 22/25] =?UTF-8?q?=E3=80=90PAC=E3=80=91feat=EF=BC=9A?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=8E=E4=BB=A3=E7=A0=81=E5=BA=93=E7=BB=B4?= =?UTF-8?q?=E5=BA=A6=E6=9F=A5=E7=9C=8B=E5=AF=B9=E5=BA=94=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=BA=93=E4=BA=8B=E4=BB=B6=20#8122?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/service/PipelineWebhookService.kt | 14 +++++++++++++- .../service/PipelineWebhookUpgradeService.kt | 10 +++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) 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 f0f1fd6041d..f571c47bb1f 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 @@ -150,7 +150,7 @@ class PipelineWebhookService @Autowired constructor( repositoryHashId = repository.repoHashId, eventType = eventType?.name ?: "", externalId = repository.getExternalId(), - externalName = repository.projectName + externalName = getExternalName(scmType = scmType, repository.projectName) ) pipelineWebhookDao.save( dslContext = dslContext, @@ -320,6 +320,18 @@ class PipelineWebhookService @Autowired constructor( return repoSplit[1].trim() } + /** + * 获取代码库平台仓库名 + */ + fun getExternalName(scmType: ScmType, projectName: String): String { + val repoSplit = projectName.split("/") + // 如果代码库是svn类型,并且项目名是三层的,比如a/b/c,那对应的rep_name是b,工蜂svn webhook返回的rep_name结构 + if (scmType == ScmType.CODE_SVN && repoSplit.size == 3) { + return repoSplit[1].trim() + } + return projectName + } + fun listWebhook( userId: String, projectId: String, 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 08922a6e3ef..85565e6e332 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 @@ -383,11 +383,19 @@ class PipelineWebhookUpgradeService( else -> null } + val externalName = when { + repository != null -> pipelineWebhookService.getExternalName( + scmType = repository.getScmType(), + projectName = repository.projectName + ) + + else -> webhook.projectName + } pipelineWebhookDao.updateWebhookEventInfo( dslContext = dslContext, eventType = elementEventType?.name ?: "", externalId = repository?.getExternalId(), - externalName = repository?.projectName ?: webhook.projectName, + externalName = externalName, projectId = projectId, pipelineId = pipelineId, taskId = webhook.taskId!!, From 14dd7fa711d1c585262feb81861a0f1b5194b790 Mon Sep 17 00:00:00 2001 From: mingshewhe Date: Thu, 30 Nov 2023 22:06:19 +0800 Subject: [PATCH 23/25] =?UTF-8?q?=E3=80=90PAC=E3=80=91feat=EF=BC=9A?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=8E=E4=BB=A3=E7=A0=81=E5=BA=93=E7=BB=B4?= =?UTF-8?q?=E5=BA=A6=E6=9F=A5=E7=9C=8B=E5=AF=B9=E5=BA=94=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=BA=93=E4=BA=8B=E4=BB=B6=20#8122?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/engine/service/PipelineWebhookUpgradeService.kt | 1 + 1 file changed, 1 insertion(+) 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 85565e6e332..88f97af9932 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 @@ -325,6 +325,7 @@ class PipelineWebhookUpgradeService( } while (pipelines.size == 1000) } + @Suppress("CyclomaticComplexMethod") private fun updatePipelineEventInfo( projectId: String, pipelineId: String, From 4a2fa86bff70bff63fced7ad1556a729859dbb2c Mon Sep 17 00:00:00 2001 From: mingshewhe Date: Thu, 30 Nov 2023 22:16:39 +0800 Subject: [PATCH 24/25] =?UTF-8?q?=E3=80=90PAC=E3=80=91feat=EF=BC=9A?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=8E=E4=BB=A3=E7=A0=81=E5=BA=93=E7=BB=B4?= =?UTF-8?q?=E5=BA=A6=E6=9F=A5=E7=9C=8B=E5=AF=B9=E5=BA=94=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=BA=93=E4=BA=8B=E4=BB=B6=20#8122?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/engine/service/PipelineWebhookUpgradeService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 88f97af9932..9ec1ca72d46 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 @@ -325,7 +325,7 @@ class PipelineWebhookUpgradeService( } while (pipelines.size == 1000) } - @Suppress("CyclomaticComplexMethod") + @Suppress("CyclomaticComplexMethod", "ComplexMethod") private fun updatePipelineEventInfo( projectId: String, pipelineId: String, From a40857b22e967342adb6b4e4e2cec0e436a23038 Mon Sep 17 00:00:00 2001 From: ruotiantang Date: Fri, 1 Dec 2023 10:55:41 +0800 Subject: [PATCH 25/25] =?UTF-8?q?=E4=BC=98=E5=8C=96GoAgent=E5=AF=B9?= =?UTF-8?q?=E4=BA=8E=E5=90=8E=E5=8F=B0=E8=B5=84=E6=BA=90=E5=8D=A0=E7=94=A8?= =?UTF-8?q?=20#9597?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/agent/agent/Makefile | 48 ++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/agent/agent/Makefile b/src/agent/agent/Makefile index d4d5b39316d..588b387ad8d 100644 --- a/src/agent/agent/Makefile +++ b/src/agent/agent/Makefile @@ -38,64 +38,64 @@ macos_no_cgo: build_macos_no_cgo build_macos_arm64_no_cgo build_linux: test clean i18nfilegen mkdir -p $(BINDIR) - GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ${BUILD_FLAGS} -o $(BINDIR)/devopsDaemon_linux $(CMDDIR)/daemon/main.go + GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/devopsDaemon_linux $(CMDDIR)/daemon/main.go GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/devopsAgent_linux $(CMDDIR)/agent/main.go - GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ${BUILD_FLAGS} -o $(BINDIR)/upgrader_linux $(CMDDIR)/upgrader/main.go - GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ${BUILD_FLAGS} -o $(BINDIR)/installer_linux $(CMDDIR)/installer/main.go + GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/upgrader_linux $(CMDDIR)/upgrader/main.go + GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/installer_linux $(CMDDIR)/installer/main.go ls -la $(BINDIR) build_linux_arm64: test clean i18nfilegen mkdir -p $(BINDIR) - GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build ${BUILD_FLAGS} -o $(BINDIR)/devopsDaemon_linux_arm64 $(CMDDIR)/daemon/main.go + GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/devopsDaemon_linux_arm64 $(CMDDIR)/daemon/main.go GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/devopsAgent_linux_arm64 $(CMDDIR)/agent/main.go - GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build ${BUILD_FLAGS} -o $(BINDIR)/upgrader_linux_arm64 $(CMDDIR)/upgrader/main.go - GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build ${BUILD_FLAGS} -o $(BINDIR)/installer_linux_arm64 $(CMDDIR)/installer/main.go + GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/upgrader_linux_arm64 $(CMDDIR)/upgrader/main.go + GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/installer_linux_arm64 $(CMDDIR)/installer/main.go ls -la $(BINDIR) build_linux_mips64: test clean i18nfilegen mkdir -p $(BINDIR) - GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build ${BUILD_FLAGS} -o $(BINDIR)/devopsDaemon_linux_mips64 $(CMDDIR)/daemon/main.go + GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/devopsDaemon_linux_mips64 $(CMDDIR)/daemon/main.go GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/devopsAgent_linux_mips64 $(CMDDIR)/agent/main.go - GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build ${BUILD_FLAGS} -o $(BINDIR)/upgrader_linux_mips64 $(CMDDIR)/upgrader/main.go - GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build ${BUILD_FLAGS} -o $(BINDIR)/installer_linux_mips64 $(CMDDIR)/installer/main.go + GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/upgrader_linux_mips64 $(CMDDIR)/upgrader/main.go + GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/installer_linux_mips64 $(CMDDIR)/installer/main.go ls -la $(BINDIR) # Telegraf 的 cpu和diskio 插件采集使用的 shirou 包需要开启cgo才可以在darwin情况下采集成功 build_macos: test clean i18nfilegen mkdir -p $(BINDIR) - GO111MODULE=on CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build ${BUILD_FLAGS} -o $(BINDIR)/devopsDaemon_macos $(CMDDIR)/daemon/main.go + GO111MODULE=on CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/devopsDaemon_macos $(CMDDIR)/daemon/main.go GO111MODULE=on CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/devopsAgent_macos $(CMDDIR)/agent/main.go - GO111MODULE=on CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build ${BUILD_FLAGS} -o $(BINDIR)/upgrader_macos $(CMDDIR)/upgrader/main.go - GO111MODULE=on CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build ${BUILD_FLAGS} -o $(BINDIR)/installer_macos $(CMDDIR)/installer/main.go + GO111MODULE=on CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/upgrader_macos $(CMDDIR)/upgrader/main.go + GO111MODULE=on CGO_ENABLED=1 GOOS=darwin GOARCH=amd64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/installer_macos $(CMDDIR)/installer/main.go ls -la $(BINDIR) build_macos_arm64: test clean i18nfilegen mkdir -p $(BINDIR) - GO111MODULE=on CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build ${BUILD_FLAGS} -o $(BINDIR)/devopsDaemon_macos_arm64 $(CMDDIR)/daemon/main.go + GO111MODULE=on CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/devopsDaemon_macos_arm64 $(CMDDIR)/daemon/main.go GO111MODULE=on CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/devopsAgent_macos_arm64 $(CMDDIR)/agent/main.go - GO111MODULE=on CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build ${BUILD_FLAGS} -o $(BINDIR)/upgrader_macos_arm64 $(CMDDIR)/upgrader/main.go - GO111MODULE=on CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build ${BUILD_FLAGS} -o $(BINDIR)/installer_macos_arm64 $(CMDDIR)/installer/main.go + GO111MODULE=on CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/upgrader_macos_arm64 $(CMDDIR)/upgrader/main.go + GO111MODULE=on CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/installer_macos_arm64 $(CMDDIR)/installer/main.go ls -la $(BINDIR) # 方便统一交叉编译,这里会提供不开启cgo的macos编译,但是其监控的 cpu和diskio 会没有数据 build_macos_no_cgo: test clean i18nfilegen mkdir -p $(BINDIR) - GO111MODULE=on CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build ${BUILD_FLAGS} -o $(BINDIR)/devopsDaemon_macos $(CMDDIR)/daemon/main.go + GO111MODULE=on CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/devopsDaemon_macos $(CMDDIR)/daemon/main.go GO111MODULE=on CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/devopsAgent_macos $(CMDDIR)/agent/main.go - GO111MODULE=on CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build ${BUILD_FLAGS} -o $(BINDIR)/upgrader_macos $(CMDDIR)/upgrader/main.go - GO111MODULE=on CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build ${BUILD_FLAGS} -o $(BINDIR)/installer_macos $(CMDDIR)/installer/main.go + GO111MODULE=on CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/upgrader_macos $(CMDDIR)/upgrader/main.go + GO111MODULE=on CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/installer_macos $(CMDDIR)/installer/main.go ls -la $(BINDIR) build_macos_arm64_no_cgo: test clean i18nfilegen mkdir -p $(BINDIR) - GO111MODULE=on CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build ${BUILD_FLAGS} -o $(BINDIR)/devopsDaemon_macos_arm64 $(CMDDIR)/daemon/main.go + GO111MODULE=on CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/devopsDaemon_macos_arm64 $(CMDDIR)/daemon/main.go GO111MODULE=on CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/devopsAgent_macos_arm64 $(CMDDIR)/agent/main.go - GO111MODULE=on CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build ${BUILD_FLAGS} -o $(BINDIR)/upgrader_macos_arm64 $(CMDDIR)/upgrader/main.go - GO111MODULE=on CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build ${BUILD_FLAGS} -o $(BINDIR)/installer_macos_arm64 $(CMDDIR)/installer/main.go + GO111MODULE=on CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/upgrader_macos_arm64 $(CMDDIR)/upgrader/main.go + GO111MODULE=on CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/installer_macos_arm64 $(CMDDIR)/installer/main.go ls -la $(BINDIR) build_windows: test clean i18nfilegen mkdir -p $(BINDIR) - GO111MODULE=on CGO_ENABLED=0 GOOS=windows GOARCH=386 go build ${BUILD_FLAGS} -o $(BINDIR)/devopsDaemon.exe $(CMDDIR)/daemon/main_win.go + GO111MODULE=on CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/devopsDaemon.exe $(CMDDIR)/daemon/main_win.go GO111MODULE=on CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/devopsAgent.exe $(CMDDIR)/agent/main.go - GO111MODULE=on CGO_ENABLED=0 GOOS=windows GOARCH=386 go build ${BUILD_FLAGS} -o $(BINDIR)/upgrader.exe $(CMDDIR)/upgrader/main.go - GO111MODULE=on CGO_ENABLED=0 GOOS=windows GOARCH=386 go build ${BUILD_FLAGS} -o $(BINDIR)/installer.exe $(CMDDIR)/installer/main.go + GO111MODULE=on CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/upgrader.exe $(CMDDIR)/upgrader/main.go + GO111MODULE=on CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -tags=${BUILD_OUT_TAG} ${BUILD_FLAGS} -o $(BINDIR)/installer.exe $(CMDDIR)/installer/main.go ls -la $(BINDIR) clean: