Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #20 from mixalturek/master
[JENKINS-23185] Setting build status to FAILURE for new error when error...
  • Loading branch information
mixalturek committed Jul 27, 2014
2 parents a490025 + cb4e204 commit 87401a0
Showing 1 changed file with 19 additions and 10 deletions.
Expand Up @@ -17,33 +17,42 @@ public Result evaluateBuildResult(
CppcheckConfigSeverityEvaluation severityEvaluation) {

if (isErrorCountExceeded(errorsCount, severityEvaluation.getFailureThreshold())) {
CppcheckLogger.log(listener, "Setting build status to FAILURE since total number of errors"
+ " exceeds the threshold value '" + severityEvaluation.getFailureThreshold() + "'.");
CppcheckLogger.log(listener,
"Setting build status to FAILURE since total number of issues '"
+ errorsCount + "' exceeds the threshold value '"
+ severityEvaluation.getFailureThreshold() + "'.");
return Result.FAILURE;
}
if (isErrorCountExceeded(newErrorsCount, severityEvaluation.getNewFailureThreshold())) {
CppcheckLogger.log(listener, "Setting build status to FAILURE since total number of new errors"
+ " exceeds the threshold value '" + severityEvaluation.getNewFailureThreshold() + "'.");
CppcheckLogger.log(listener,
"Setting build status to FAILURE since number of new issues '"
+ newErrorsCount + "' exceeds the threshold value '"
+ severityEvaluation.getNewFailureThreshold() + "'.");
return Result.FAILURE;
}
if (isErrorCountExceeded(errorsCount, severityEvaluation.getThreshold())) {
CppcheckLogger.log(listener, "Setting build status to UNSTABLE since total number of errors"
+ " exceeds the threshold value '" + severityEvaluation.getThreshold() + "'.");
CppcheckLogger.log(listener,
"Setting build status to UNSTABLE since total number of issues '"
+ errorsCount + "' exceeds the threshold value '"
+ severityEvaluation.getThreshold() + "'.");
return Result.UNSTABLE;
}
if (isErrorCountExceeded(newErrorsCount, severityEvaluation.getNewThreshold())) {
CppcheckLogger.log(listener, "Setting build status to UNSTABLE since total number of new errors"
+ " exceeds the threshold value '" + severityEvaluation.getNewThreshold() + "'.");
CppcheckLogger.log(listener,
"Setting build status to UNSTABLE since number of new issues '"
+ newErrorsCount + "' exceeds the threshold value '"
+ severityEvaluation.getNewThreshold() + "'.");
return Result.UNSTABLE;
}

CppcheckLogger.log(listener, "Not changing build status, since no threshold has been exceeded");
CppcheckLogger.log(listener,
"Not changing build status, since no threshold has been exceeded.");
return Result.SUCCESS;
}

private boolean isErrorCountExceeded(final int errorCount, final String errorThreshold) {
if (errorCount > 0 && CppcheckMetricUtil.isValid(errorThreshold)) {
return errorCount > CppcheckMetricUtil.convert(errorThreshold);
return errorCount >= CppcheckMetricUtil.convert(errorThreshold);
}
return false;
}
Expand Down

0 comments on commit 87401a0

Please sign in to comment.