Skip to content

Commit

Permalink
Merge pull request TencentBlueKing#5437 from JamiKX1/issue_5435
Browse files Browse the repository at this point in the history
feat: 质量红线拦截结果页不同结果用不同颜色显示 TencentBlueKing#5435
  • Loading branch information
irwinsun authored Nov 3, 2021
2 parents 5e3fdb4 + 8533257 commit 86358d3
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ data class RuleCheckSingleResult(
@ApiModelProperty("规则名称", required = true)
val ruleName: String,
@ApiModelProperty("失败信息", required = true)
val messagePairs: List<Pair<String, String/*detail*/>>
val messagePairs: List<Triple<String, String/*detail*/, Boolean>>
)
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,22 @@ class BuildLogPrinter(
executeCount = executeCount
)

fun addGreenLine(
buildId: String,
message: String,
tag: String,
jobId: String?,
executeCount: Int,
subTag: String? = null
) = addLine(
buildId = buildId,
message = Ansi().bold().fgGreen().a(message).reset().toString(),
tag = tag,
subTag = subTag,
jobId = jobId,
executeCount = executeCount
)

fun addRedLine(
buildId: String,
message: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class PipelineBuildQualityService(
task.taskParams[BS_ATOM_STATUS_REFRESH_DELAY_MILLS] = 5000
task.taskParams[QUALITY_RESULT] = checkResult.success
} else {
buildLogPrinter.addRedLine(
buildLogPrinter.addLine(
buildId = buildId,
message = "质量红线($atomDesc)检测被拦截",
tag = elementId,
Expand All @@ -315,21 +315,31 @@ class PipelineBuildQualityService(
)

checkResult.resultList.forEach {
buildLogPrinter.addRedLine(
buildLogPrinter.addLine(
buildId = buildId,
message = "规则:${it.ruleName}",
tag = elementId,
jobId = task.containerHashId,
executeCount = task.executeCount ?: 1
)
it.messagePairs.forEach { message ->
buildLogPrinter.addRedLine(
buildId = buildId,
message = message.first + " " + message.second,
tag = elementId,
jobId = task.containerHashId,
executeCount = task.executeCount ?: 1
)
if (message.third) {
buildLogPrinter.addLine(
buildId = buildId,
message = message.first + " " + message.second,
tag = elementId,
jobId = task.containerHashId,
executeCount = task.executeCount ?: 1
)
} else {
buildLogPrinter.addRedLine(
buildId = buildId,
message = message.first + " " + message.second,
tag = elementId,
jobId = task.containerHashId,
executeCount = task.executeCount ?: 1
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,11 @@ class QualityRuleCheckService @Autowired constructor(
}
val nullMsg = if (it.actualValue == null) "你可能并未添加工具或打开相应规则。" else ""
val detailMsg = getDetailMsg(it, params)
Pair(
Triple(
sb.append("${it.indicatorName}当前值(${it.actualValue}),期望$thresholdOperationName${it.value}$nullMsg")
.toString(),
detailMsg
detailMsg,
it.pass
)
}
return RuleCheckSingleResult(ruleName, messageList)
Expand Down

0 comments on commit 86358d3

Please sign in to comment.