use of com.synopsys.integration.detect.configuration.enumeration.ExitCodeType in project synopsys-detect by blackducksoftware.
the class ExitManager method exit.
public ExitResult exit(ExitOptions exitOptions) {
long startTime = exitOptions.getStartTime();
boolean forceSuccessExit = exitOptions.shouldForceSuccessExit();
boolean shouldExit = exitOptions.shouldExit();
// Generally, when requesting a failure status, an exit code is also requested, but if it is not, we default to an unknown error.
if (statusManager.hasAnyFailure()) {
eventSystem.publishEvent(Event.ExitCode, new ExitCodeRequest(ExitCodeType.FAILURE_UNKNOWN_ERROR, "A failure status was requested by one or more of Detect's tools."));
}
// Find the final (as requested) exit code
ExitCodeType finalExitCode = exitCodeManager.getWinningExitCode();
// Print detect's status
statusManager.logDetectResults(new Slf4jIntLogger(logger), finalExitCode);
// Print duration of run
long endTime = System.currentTimeMillis();
String duration = DurationFormatUtils.formatPeriod(startTime, endTime, "HH'h' mm'm' ss's' SSS'ms'");
logger.info("Detect duration: {}", duration);
// Exit with formal exit code
if (finalExitCode != ExitCodeType.SUCCESS && forceSuccessExit) {
logger.warn("Forcing success: Exiting with exit code 0. Ignored exit code was {}.", finalExitCode.getExitCode());
} else if (finalExitCode != ExitCodeType.SUCCESS) {
logger.error("Exiting with code {} - {}", finalExitCode.getExitCode(), finalExitCode);
}
if (!shouldExit) {
logger.info("Would normally exit({}) but it is overridden.", finalExitCode.getExitCode());
}
return new ExitResult(finalExitCode, forceSuccessExit, shouldExit);
}
Aggregations