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

feat: 当 mr 触发时, webhookinfo 中增加 mr 的源分支 和 id #6153 #6208

Merged
merged 3 commits into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -121,6 +121,7 @@ const val BK_REPO_SVN_WEBHOOK_RELATIVE_PATH = "BK_CI_REPO_SVN_WEBHOOK_INCLUDE_PA
const val BK_REPO_SVN_WEBHOOK_EXCLUDE_PATHS = "BK_CI_REPO_SVN_WEBHOOK_EXCLUDE_PATHS"
const val BK_REPO_SVN_WEBHOOK_INCLUDE_USERS = "BK_CI_REPO_SVN_WEBHOOK_INCLUDE_USERS"
const val BK_REPO_SVN_WEBHOOK_EXCLUDE_USERS = "BK_CI_REPO_SVN_WEBHOOK_EXCLUDE_USERS"
const val BK_REPO_SVN_WEBHOOK_FINAL_INCLUDE_PATH = "BK_REPO_SVN_WEBHOOK_FINAL_INCLUDE_PATH"

const val PIPELINE_WEBHOOK_MR_ID = "BK_CI_HOOK_MR_ID" // bk_hookMergeRequestId
const val PIPELINE_WEBHOOK_MR_COMMITTER = "BK_CI_HOOK_MR_COMMITTER" // "bk_hookMergeRequest_committer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ package com.tencent.devops.common.webhook.service.code.param
import com.tencent.devops.common.pipeline.pojo.element.trigger.CodeSVNWebHookTriggerElement
import com.tencent.devops.common.webhook.pojo.code.BK_REPO_SVN_WEBHOOK_EXCLUDE_PATHS
import com.tencent.devops.common.webhook.pojo.code.BK_REPO_SVN_WEBHOOK_EXCLUDE_USERS
import com.tencent.devops.common.webhook.pojo.code.BK_REPO_SVN_WEBHOOK_FINAL_INCLUDE_PATH
import com.tencent.devops.common.webhook.pojo.code.BK_REPO_SVN_WEBHOOK_INCLUDE_USERS
import com.tencent.devops.common.webhook.pojo.code.BK_REPO_SVN_WEBHOOK_RELATIVE_PATH
import com.tencent.devops.common.webhook.pojo.code.MATCH_PATHS
import com.tencent.devops.common.webhook.pojo.code.WebHookParams
import com.tencent.devops.common.webhook.service.code.matcher.ScmWebhookMatcher
import com.tencent.devops.repository.pojo.Repository
Expand All @@ -58,6 +60,7 @@ class SvnWebHookStartParam : ScmWebhookStartParams<CodeSVNWebHookTriggerElement>
startParams[BK_REPO_SVN_WEBHOOK_EXCLUDE_PATHS] = element.excludePaths ?: ""
startParams[BK_REPO_SVN_WEBHOOK_INCLUDE_USERS] = element.includeUsers?.joinToString(",") ?: ""
startParams[BK_REPO_SVN_WEBHOOK_EXCLUDE_USERS] = element.excludeUsers?.joinToString(",") ?: ""
startParams[BK_REPO_SVN_WEBHOOK_FINAL_INCLUDE_PATH] = matchResult.extra[MATCH_PATHS] ?: ""
startParams.putAll(matcher.retrieveParams())
return startParams
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ data class WebhookInfo(
val webhookMessage: String?,
val webhookCommitId: String?,
// 合并后commitId
val webhookMergeCommitSha: String?
val webhookMergeCommitSha: String?,
// 源分支
val webhookSourceBranch: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import com.tencent.devops.common.redis.RedisOperation
import com.tencent.devops.common.service.trace.TraceTag
import com.tencent.devops.common.webhook.pojo.code.BK_REPO_GIT_WEBHOOK_EVENT_TYPE
import com.tencent.devops.common.webhook.pojo.code.BK_REPO_GIT_WEBHOOK_MR_MERGE_COMMIT_SHA
import com.tencent.devops.common.webhook.pojo.code.BK_REPO_GIT_WEBHOOK_MR_SOURCE_BRANCH
import com.tencent.devops.common.webhook.pojo.code.BK_REPO_WEBHOOK_REPO_URL
import com.tencent.devops.common.webhook.pojo.code.PIPELINE_WEBHOOK_BRANCH
import com.tencent.devops.common.webhook.pojo.code.PIPELINE_WEBHOOK_COMMIT_MESSAGE
Expand Down Expand Up @@ -1144,7 +1145,8 @@ class PipelineRuntimeService @Autowired constructor(
params[PIPELINE_WEBHOOK_EVENT_TYPE] as String?
},
webhookCommitId = params[PIPELINE_WEBHOOK_REVISION] as String?,
webhookMergeCommitSha = params[BK_REPO_GIT_WEBHOOK_MR_MERGE_COMMIT_SHA] as String?
webhookMergeCommitSha = params[BK_REPO_GIT_WEBHOOK_MR_MERGE_COMMIT_SHA] as String?,
webhookSourceBranch = params[BK_REPO_GIT_WEBHOOK_MR_SOURCE_BRANCH] as String?
),
formatted = false
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class PipelineJobBean(
fun execute(context: JobExecutionContext?) {
val jobKey = context?.jobDetail?.key ?: return
val comboKey = jobKey.name
val comboKeys = comboKey.split("_")
val comboKeys = comboKey.split(Regex("_"), 3)
val pipelineId = comboKeys[0]
val crontabMd5 = comboKeys[1]
val projectId = comboKeys[2]
Expand Down