Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复3.0模板一些bug #10757

Merged
merged 25 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fcd35ca
feat:流水线版本管理机制 #8161 模板常量实例化时转换成流水线常量
mingshewhe Jul 30, 2024
138535c
feat:流水线版本管理机制 #8161 模板常量实例化时转换成流水线常量
mingshewhe Jul 30, 2024
e986b17
【PAC】feat:开启PAC模式的代码库支持自动同步代码库YAML变更到蓝盾 #8130 修复没有oauth用户,执行pac流水线报错
mingshewhe Jul 31, 2024
69a79c6
feat:新建/编辑流水线时支持调试流水线 #8164 修复构建历史区分源材料分支和触发分支搜索
mingshewhe Aug 1, 2024
9c2162c
feat:新建/编辑流水线时支持调试流水线 #8164 修复构建历史区分源材料分支和触发分支搜索
mingshewhe Aug 1, 2024
57f8791
feat:新建/编辑流水线时支持调试流水线 #8164 修复构建历史区分源材料分支和触发分支搜索
mingshewhe Aug 1, 2024
d53a163
feat:流水线版本管理机制 #8161 空白模板名称由Blank改成Default
mingshewhe Aug 1, 2024
6055971
【PAC】feat:开启PAC模式的代码库支持自动同步代码库YAML变更到蓝盾 #8130 修复社区版不应该有GIT代码库类型
mingshewhe Aug 1, 2024
7dd34a4
feat:工蜂MR触发器支持设置监听的action #8949 修改gitlab不触发问题
mingshewhe Aug 1, 2024
807ac11
feat:工蜂MR触发器支持设置监听的action #8949 修改gitlab不触发问题
mingshewhe Aug 2, 2024
c520098
feat:新建/编辑流水线时支持调试流水线 #8164 修复构建历史区分源材料分支和触发分支搜索
mingshewhe Aug 2, 2024
6609449
feat:流水线版本管理机制 #8161 修复T_PIPELINE_SETTING表dead lock
mingshewhe Aug 2, 2024
0a55a81
bug:流水线实例复制功能没有复制相应实例的参数值 #10580
mingshewhe Aug 3, 2024
3e34bd3
bug:流水线实例复制功能没有复制相应实例的参数值 #10580
mingshewhe Aug 3, 2024
d6e18e6
feat:流水线版本管理机制 #8161 修复T_PIPELINE_SETTING表dead lock
mingshewhe Aug 3, 2024
1b259d0
bug:流水线实例复制功能没有复制相应实例的参数值 #10580 模板参数保存时清理无用下拉框数据
mingshewhe Aug 5, 2024
a312c4c
feat:工蜂MR触发器支持设置监听的action #8949 修复webhook request 保存时event_message超长
mingshewhe Aug 5, 2024
fdd6614
feat:流水线版本管理机制 #8161 修复T_PIPELINE_SETTING表dead lock
mingshewhe Aug 5, 2024
6c1d317
feat:新建/编辑流水线时支持调试流水线 #8164 修复构建历史区分源材料分支和触发分支搜索
mingshewhe Aug 5, 2024
79cb611
feat:新建/编辑流水线时支持调试流水线 #8164 修复构建历史区分源材料分支和触发分支搜索
mingshewhe Aug 5, 2024
d704b67
Revert "bug:流水线实例复制功能没有复制相应实例的参数值 #10580"
mingshewhe Aug 5, 2024
bca3ec2
Revert "bug:流水线实例复制功能没有复制相应实例的参数值 #10580"
mingshewhe Aug 5, 2024
628202e
feat:新建/编辑流水线时支持调试流水线 #8164 修复构建历史区分源材料分支和触发分支搜索
mingshewhe Aug 5, 2024
a41f1d0
feat:新建/编辑流水线时支持调试流水线 #8164 修复构建历史区分源材料分支和触发分支搜索
mingshewhe Aug 5, 2024
c306839
feat:新建/编辑流水线时支持调试流水线 #8164 修复复制模板实例缺少templateVersion字段
mingshewhe Aug 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,34 @@
package com.tencent.devops.common.db.utils

import com.mysql.cj.jdbc.exceptions.MySQLTransactionRollbackException
import java.math.BigDecimal
import java.sql.Timestamp
import org.jooq.DatePart
import org.jooq.Field
import org.jooq.Record
import org.jooq.SelectOptionStep
import org.jooq.SelectUnionStep
import org.jooq.exception.DataAccessException
import org.jooq.impl.DSL
import org.springframework.dao.DeadlockLoserDataAccessException
import java.math.BigDecimal
import java.sql.Timestamp

object JooqUtils {

const val JooqDeadLockMessage = "Deadlock found when trying to get lock; try restarting transaction"

fun <T> retryWhenDeadLock(action: () -> T): T {
fun <T> retryWhenDeadLock(retryTime: Int = 1, action: () -> T): T {
return try {
action()
} catch (dae: DataAccessException) {
if (dae.isDeadLock()) action() else throw dae
if (retryTime - 1 < 0) {
throw dae
}
if (dae.isDeadLock()) retryWhenDeadLock(retryTime - 1, action) else throw dae
} catch (dae: DeadlockLoserDataAccessException) {
if (retryTime - 1 < 0) {
throw dae
}
retryWhenDeadLock(retryTime - 1, action)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.tencent.devops.common.db.utils

import org.jooq.exception.DataAccessException
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test

class JooqUtilsTest {
Expand All @@ -18,6 +19,19 @@ class JooqUtilsTest {
Assertions.assertEquals(expect, actual)
}

@Test
@DisplayName("重试多次")
fun retryWhenDeadLock_2() {
var actual = 0
JooqUtils.retryWhenDeadLock(3) {
if (actual++ < 3) {
throw DataAccessException("mock sql dead lock; ${JooqUtils.JooqDeadLockMessage}")
}
}
val expect = 4 // retry
Assertions.assertEquals(expect, actual)
}

@Test
fun assertThrowsRetryWhenDeadLock() {
var actual = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ data class TriggerContainer(
@get:Schema(title = "参数化构建", required = false)
var params: List<BuildFormProperty> = listOf(),
@get:Schema(title = "模板参数构建", required = false)
val templateParams: List<BuildFormProperty>? = null,
var templateParams: List<BuildFormProperty>? = null,
@get:Schema(title = "构建版本号", required = false)
var buildNo: BuildNo? = null,
@get:Schema(title =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ class GitlabWebhookElementParams : ScmWebhookElementParams<CodeGitlabWebHookTrig
} else {
EnvUtils.parseEnv(element.excludeUsers!!.joinToString(","), variables)
}
if (element.branchName == null) {
return null
}
params.version = element.version
when {
// action上线后【流水线配置层面】兼容存量merge_request_accept和push事件
Expand Down Expand Up @@ -103,7 +100,7 @@ class GitlabWebhookElementParams : ScmWebhookElementParams<CodeGitlabWebHookTrig
params.includePushAction = WebhookUtils.joinToString(element.includePushAction)
}
}
params.branchName = EnvUtils.parseEnv(element.branchName!!, variables)
params.branchName = EnvUtils.parseEnv(element.branchName ?: "", variables)
params.codeType = CodeType.GITLAB
params.eventType = element.eventType
params.block = element.block ?: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,19 +234,19 @@ interface ApigwBuildResourceV4 {
)
@QueryParam("updateTimeDesc")
updateTimeDesc: Boolean? = null,
@Parameter(description = "代码库别名", required = false)
@Parameter(description = "源材料代码库别名", required = false)
@QueryParam("materialAlias")
materialAlias: List<String>?,
@Parameter(description = "代码库URL", required = false)
@QueryParam("materialUrl")
materialUrl: String?,
@Parameter(description = "分支", required = false)
@Parameter(description = "源材料分支", required = false)
@QueryParam("materialBranch")
materialBranch: List<String>?,
@Parameter(description = "commitId", required = false)
@Parameter(description = "源材料commitId", required = false)
@QueryParam("materialCommitId")
materialCommitId: String?,
@Parameter(description = "commitMessage", required = false)
@Parameter(description = "源材料commitMessage", required = false)
@QueryParam("materialCommitMessage")
materialCommitMessage: String?,
@Parameter(description = "状态", required = false)
Expand Down Expand Up @@ -296,7 +296,13 @@ interface ApigwBuildResourceV4 {
startUser: List<String>?,
@Parameter(description = "是否查询归档数据", required = false)
@QueryParam("archiveFlag")
archiveFlag: Boolean? = false
archiveFlag: Boolean? = false,
@Parameter(description = "触发代码库", required = false)
@QueryParam("triggerAlias")
triggerAlias: List<String>? = null,
@Parameter(description = "触发分支", required = false)
@QueryParam("triggerBranch")
triggerBranch: List<String>? = null
): Result<BuildHistoryPage<BuildHistory>>

@Operation(summary = "获取流水线手动启动参数", tags = ["v4_app_build_startInfo", "v4_user_build_startInfo"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ class ApigwBuildResourceV4Impl @Autowired constructor(
buildNoEnd: Int?,
buildMsg: String?,
startUser: List<String>?,
archiveFlag: Boolean?
archiveFlag: Boolean?,
triggerAlias: List<String>?,
triggerBranch: List<String>?
): Result<BuildHistoryPage<BuildHistory>> {
logger.info(
"OPENAPI_BUILD_V4|$userId|get history build|$projectId|$pipelineId|$page|$pageSize" +
Expand Down Expand Up @@ -165,7 +167,9 @@ class ApigwBuildResourceV4Impl @Autowired constructor(
buildNoEnd = buildNoEnd,
buildMsg = buildMsg,
startUser = startUser,
archiveFlag = archiveFlag
archiveFlag = archiveFlag,
triggerAlias = triggerAlias,
triggerBranch = triggerBranch
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,12 @@ interface AppPipelineBuildResource {
buildMsg: String?,
@Parameter(description = "查看指定版本调试数据", required = false, example = "false")
@QueryParam("version")
customVersion: Int? = null
customVersion: Int? = null,
@Parameter(description = "触发代码库", required = false)
@QueryParam("triggerAlias")
triggerAlias: List<String>?,
@Parameter(description = "触发分支", required = false)
@QueryParam("triggerBranch")
triggerBranch: List<String>?
): Result<BuildHistoryPage<BuildHistory>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,13 @@ interface ServiceBuildResource {
archiveFlag: Boolean? = false,
@Parameter(description = "查看指定版本调试数据", required = false, example = "false")
@QueryParam("version")
customVersion: Int? = null
customVersion: Int? = null,
@Parameter(description = "触发代码库", required = false)
@QueryParam("triggerAlias")
triggerAlias: List<String>? = null,
@Parameter(description = "触发分支", required = false)
@QueryParam("triggerBranch")
triggerBranch: List<String>? = null
): Result<BuildHistoryPage<BuildHistory>>

@Operation(summary = "获取构建详情")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import com.tencent.devops.common.pipeline.pojo.BuildParameters
import com.tencent.devops.common.pipeline.pojo.StageReviewRequest
import com.tencent.devops.common.pipeline.pojo.element.Element
import com.tencent.devops.common.web.annotation.BkField
import com.tencent.devops.process.enums.HistorySearchType
import com.tencent.devops.process.pojo.BuildHistory
import com.tencent.devops.process.pojo.BuildHistoryRemark
import com.tencent.devops.process.pojo.BuildId
Expand Down Expand Up @@ -400,13 +401,13 @@ interface UserBuildResource {
@Parameter(description = "每页多少条", required = false, example = "20")
@QueryParam("pageSize")
pageSize: Int?,
@Parameter(description = "代码库别名", required = false)
@Parameter(description = "源材料代码库别名", required = false)
@QueryParam("materialAlias")
materialAlias: List<String>?,
@Parameter(description = "代码库URL", required = false)
@QueryParam("materialUrl")
materialUrl: String?,
@Parameter(description = "分支", required = false)
@Parameter(description = "源材料分支", required = false)
@QueryParam("materialBranch")
materialBranch: List<String>?,
@Parameter(description = "commitId", required = false)
Expand Down Expand Up @@ -462,7 +463,13 @@ interface UserBuildResource {
archiveFlag: Boolean? = false,
@Parameter(description = "查看指定版本调试数据", required = false, example = "false")
@QueryParam("version")
customVersion: Int? = null
customVersion: Int? = null,
@Parameter(description = "触发代码库", required = false)
@QueryParam("triggerAlias")
triggerAlias: List<String>?,
@Parameter(description = "触发分支", required = false)
@QueryParam("triggerBranch")
triggerBranch: List<String>?
): Result<BuildHistoryPage<BuildHistory>>

@Operation(summary = "修改流水线备注")
Expand Down Expand Up @@ -534,7 +541,13 @@ interface UserBuildResource {
pipelineId: String,
@Parameter(description = "查看指定版本调试数据", required = false, example = "false")
@QueryParam("version")
debugVersion: Int? = null
debugVersion: Int? = null,
@Parameter(description = "搜索分支关键字", required = false)
@QueryParam("search")
search: String?,
@Parameter(description = "搜索类型, 触发/源材料", required = false)
@QueryParam("type")
type: HistorySearchType?
): Result<List<String>>

@Operation(summary = "获取流水线构建中的查询条件-分支")
Expand All @@ -556,7 +569,13 @@ interface UserBuildResource {
alias: List<String>?,
@Parameter(description = "查看指定版本调试数据", required = false, example = "false")
@QueryParam("debugVersion")
debugVersion: Int? = null
debugVersion: Int? = null,
@Parameter(description = "搜索分支关键字", required = false)
@QueryParam("search")
search: String?,
@Parameter(description = "搜索类型,触发/源材料", required = false)
@QueryParam("type")
type: HistorySearchType?
): Result<List<String>>

@Operation(summary = "触发审核")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.enums

/**
* 构建历史搜索类型
*/
enum class HistorySearchType {
// 触发器
TRIGGER,

// 源材料
MATERIAL
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ data class PipelineDetail(
val instanceFromTemplate: Boolean,
@get:Schema(title = "当前模板的ID", required = false)
var templateId: String?,
@get:Schema(title = "关联模板版本", required = false)
var templateVersion: Long?,
@get:Schema(title = "草稿或最新的发布版本")
val version: Int,
@get:Schema(title = "草稿或最新的发布版本名称")
Expand Down
Loading
Loading