Skip to content

Commit

Permalink
feat: 红线git评论分开发送 TencentBlueKing#6118
Browse files Browse the repository at this point in the history
  • Loading branch information
JamiKX1 committed Feb 11, 2022
1 parent 82c414e commit 862b2dc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import com.tencent.devops.plugin.api.pojo.GitCommitCheckEvent
import com.tencent.devops.plugin.utils.QualityUtils
import com.tencent.devops.process.utils.Credential
import com.tencent.devops.process.utils.CredentialUtils
import com.tencent.devops.quality.api.v2.ServiceQualityInterceptResource
import com.tencent.devops.repository.api.ServiceGithubResource
import com.tencent.devops.repository.api.ServiceOauthResource
import com.tencent.devops.repository.api.ServiceRepositoryResource
Expand Down Expand Up @@ -98,27 +99,32 @@ class ScmCheckService @Autowired constructor(private val client: Client) {
else ->
throw OperationException("不是Git 代码仓库")
}
val request = CommitCheckRequest(
projectName = repo.projectName,
url = repo.url,
type = type,
privateKey = null,
passPhrase = null,
token = token,
region = null,
commitId = commitId,
state = state,
targetUrl = targetUrl,
context = context,
description = description,
block = block,
mrRequestId = event.mergeRequestId,
reportData = QualityUtils.getQualityGitMrResult(client, event)
)
if (isOauth) {
client.get(ServiceScmOauthResource::class).addCommitCheck(request)
} else {
client.get(ServiceScmResource::class).addCommitCheck(request)
// 红线评论分开发送
val qualityHistory = client.get(ServiceQualityInterceptResource::class)
.listHistory(projectId, pipelineId, buildId).data
qualityHistory?.forEach { history ->
val request = CommitCheckRequest(
projectName = repo.projectName,
url = repo.url,
type = type,
privateKey = null,
passPhrase = null,
token = token,
region = null,
commitId = commitId,
state = state,
targetUrl = targetUrl,
context = context,
description = description,
block = block,
mrRequestId = event.mergeRequestId,
reportData = QualityUtils.getQualityGitMrResult(client, event, listOf(history.ruleHashId))
)
if (isOauth) {
client.get(ServiceScmOauthResource::class).addCommitCheck(request)
} else {
client.get(ServiceScmResource::class).addCommitCheck(request)
}
}
return repo.projectName
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ import com.tencent.devops.quality.constant.codeccToolUrlPathMap
object QualityUtils {
fun getQualityGitMrResult(
client: Client,
event: GitCommitCheckEvent
event: GitCommitCheckEvent,
ruleIds: List<String>
): Pair<List<String>, MutableMap<String, MutableList<List<String>>>> {
val projectId = event.projectId
val pipelineId = event.pipelineId
Expand All @@ -68,7 +69,7 @@ object QualityUtils {
// value:指标、预期、结果、状态
val resultMap = mutableMapOf<String, MutableList<List<String>>>()
client.get(ServiceQualityInterceptResource::class)
.listHistory(projectId, pipelineId, buildId).data?.forEach { ruleIntercept ->
.listRuleHistory(projectId, pipelineId, buildId, ruleIds).data?.forEach { ruleIntercept ->
ruleIntercept.resultMsg.forEach { interceptItem ->
val indicator = client.get(ServiceQualityIndicatorResource::class)
.get(projectId, interceptItem.indicatorId).data
Expand Down

0 comments on commit 862b2dc

Please sign in to comment.