diff --git a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/code/git/GitTagPushEvent.kt b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/code/git/GitTagPushEvent.kt index 1305ce54adf..6fa622c21de 100644 --- a/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/code/git/GitTagPushEvent.kt +++ b/src/backend/ci/core/process/api-process/src/main/kotlin/com/tencent/devops/process/pojo/code/git/GitTagPushEvent.kt @@ -39,9 +39,10 @@ data class GitTagPushEvent( val repository: GitCommitRepository, val commits: List, val total_commits_count: Int, - val operation_kind: String? + val operation_kind: String?, + val create_from: String ) : GitEvent() { companion object { const val classType = "tag_push" } -} \ No newline at end of file +} diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/code/GitWebHookMatcher.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/code/GitWebHookMatcher.kt index 7bdeb2bbada..b49580bd4a1 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/code/GitWebHookMatcher.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/code/GitWebHookMatcher.kt @@ -274,18 +274,30 @@ open class GitWebHookMatcher(val event: GitEvent) : ScmWebhookMatcher { // 匹配 val eventTag = getTag(gitTagPushEvent.ref) + val createFrom = gitTagPushEvent.create_from with(webHookParams) { if (doExcludeBranchMatch(excludeTagName, eventTag, pipelineId)) { logger.warn("Do tag event match fail for exclude branch match for pipeline: $pipelineId") return ScmWebhookMatcher.MatchResult(false) } + if (doExcludeBranchMatch(excludeBranchName, createFrom, pipelineId)) { + logger.warn("Do tag event match fail for exclude create from branch match for pipeline: $pipelineId") + return ScmWebhookMatcher.MatchResult(false) + } + val matchBranch = doIncludeBranchMatch(tagName, eventTag, pipelineId) if (matchBranch == null) { logger.warn("Do tag event match fail for include branch not match for pipeline: $pipelineId") return ScmWebhookMatcher.MatchResult(false) } + val matchFromBranch = doIncludeBranchMatch(branchName, createFrom, pipelineId) + if (matchFromBranch == null) { + logger.warn("Do tag event match fail for include create from branch not match for pipeline: $pipelineId") + return ScmWebhookMatcher.MatchResult(false) + } + logger.info("Do tag match success for pipeline: $pipelineId") return ScmWebhookMatcher.MatchResult(true, mapOf(MATCH_BRANCH to matchBranch, MATCH_PATHS to "")) } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/code/GitWebHookStartParam.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/code/GitWebHookStartParam.kt index c0f139635cc..67a3bf13726 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/code/GitWebHookStartParam.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/engine/service/code/GitWebHookStartParam.kt @@ -94,6 +94,7 @@ import com.tencent.devops.scm.pojo.BK_REPO_GIT_WEBHOOK_PUSH_MODIFY_FILE_PREFIX import com.tencent.devops.scm.pojo.BK_REPO_GIT_WEBHOOK_PUSH_OPERATION_KIND import com.tencent.devops.scm.pojo.BK_REPO_GIT_WEBHOOK_PUSH_TOTAL_COMMIT import com.tencent.devops.scm.pojo.BK_REPO_GIT_WEBHOOK_PUSH_USERNAME +import com.tencent.devops.scm.pojo.BK_REPO_GIT_WEBHOOK_TAG_CREATE_FROM import com.tencent.devops.scm.pojo.BK_REPO_GIT_WEBHOOK_TAG_NAME import com.tencent.devops.scm.pojo.BK_REPO_GIT_WEBHOOK_TAG_OPERATION import com.tencent.devops.scm.pojo.BK_REPO_GIT_WEBHOOK_TAG_USERNAME @@ -164,6 +165,7 @@ class GitWebHookStartParam( startParams[BK_REPO_GIT_WEBHOOK_TAG_OPERATION] = gitTagPushEvent.operation_kind ?: "" startParams[BK_REPO_GIT_WEBHOOK_PUSH_TOTAL_COMMIT] = gitTagPushEvent.total_commits_count startParams[BK_REPO_GIT_WEBHOOK_TAG_USERNAME] = matcher.getUsername() + startParams[BK_REPO_GIT_WEBHOOK_TAG_CREATE_FROM] = gitTagPushEvent.create_from ?: "" genCommitsParam(startParams, gitTagPushEvent.commits) }