diff --git a/plugins/commands/advisor/src/main/kotlin/AdvisorCommand.kt b/plugins/commands/advisor/src/main/kotlin/AdvisorCommand.kt index 912983d50cbe1..b654dc0e79c29 100644 --- a/plugins/commands/advisor/src/main/kotlin/AdvisorCommand.kt +++ b/plugins/commands/advisor/src/main/kotlin/AdvisorCommand.kt @@ -52,6 +52,7 @@ import org.ossreviewtoolkit.plugins.commands.api.utils.readOrtResult import org.ossreviewtoolkit.plugins.commands.api.utils.writeOrtResult import org.ossreviewtoolkit.utils.common.expandTilde import org.ossreviewtoolkit.utils.common.safeMkdirs +import org.ossreviewtoolkit.utils.ort.ORT_FAILURE_STATUS_CODE import org.ossreviewtoolkit.utils.ort.ORT_RESOLUTIONS_FILENAME import org.ossreviewtoolkit.utils.ort.ortConfigDirectory @@ -156,6 +157,6 @@ class AdvisorCommand : OrtCommand( val resolutionProvider = DefaultResolutionProvider.create(ortResultOutput, resolutionsFile) val issues = advisorRun.results.getIssues().flatMap { it.value } SeverityStatsPrinter(terminal, resolutionProvider).stats(issues) - .print().conclude(ortConfig.severeIssueThreshold, 2) + .print().conclude(ortConfig.severeIssueThreshold, ORT_FAILURE_STATUS_CODE) } } diff --git a/plugins/commands/analyzer/src/main/kotlin/AnalyzerCommand.kt b/plugins/commands/analyzer/src/main/kotlin/AnalyzerCommand.kt index 10d46fee1fccd..a2b310f57515c 100644 --- a/plugins/commands/analyzer/src/main/kotlin/AnalyzerCommand.kt +++ b/plugins/commands/analyzer/src/main/kotlin/AnalyzerCommand.kt @@ -56,6 +56,7 @@ import org.ossreviewtoolkit.plugins.packagecurationproviders.api.PackageCuration import org.ossreviewtoolkit.plugins.packagecurationproviders.api.SimplePackageCurationProvider import org.ossreviewtoolkit.utils.common.expandTilde import org.ossreviewtoolkit.utils.common.safeMkdirs +import org.ossreviewtoolkit.utils.ort.ORT_FAILURE_STATUS_CODE import org.ossreviewtoolkit.utils.ort.ORT_REPO_CONFIG_FILENAME import org.ossreviewtoolkit.utils.ort.ORT_RESOLUTIONS_FILENAME import org.ossreviewtoolkit.utils.ort.ortConfigDirectory @@ -227,6 +228,6 @@ class AnalyzerCommand : OrtCommand( val resolutionProvider = DefaultResolutionProvider.create(ortResult, resolutionsFile) val issues = analyzerRun.result.getAllIssues().flatMap { it.value } SeverityStatsPrinter(terminal, resolutionProvider).stats(issues) - .print().conclude(ortConfig.severeIssueThreshold, 2) + .print().conclude(ortConfig.severeIssueThreshold, ORT_FAILURE_STATUS_CODE) } } diff --git a/plugins/commands/scanner/src/main/kotlin/ScannerCommand.kt b/plugins/commands/scanner/src/main/kotlin/ScannerCommand.kt index 8ff470fe6a10d..c595b43ff1afc 100644 --- a/plugins/commands/scanner/src/main/kotlin/ScannerCommand.kt +++ b/plugins/commands/scanner/src/main/kotlin/ScannerCommand.kt @@ -63,6 +63,7 @@ import org.ossreviewtoolkit.scanner.provenance.DefaultProvenanceDownloader import org.ossreviewtoolkit.scanner.utils.DefaultWorkingTreeCache import org.ossreviewtoolkit.utils.common.expandTilde import org.ossreviewtoolkit.utils.common.safeMkdirs +import org.ossreviewtoolkit.utils.ort.ORT_FAILURE_STATUS_CODE import org.ossreviewtoolkit.utils.ort.ORT_RESOLUTIONS_FILENAME import org.ossreviewtoolkit.utils.ort.ortConfigDirectory @@ -154,7 +155,7 @@ class ScannerCommand : OrtCommand( val resolutionProvider = DefaultResolutionProvider.create(ortResult, resolutionsFile) val issues = scannerRun.getIssues().flatMap { it.value } SeverityStatsPrinter(terminal, resolutionProvider).stats(issues) - .print().conclude(ortConfig.severeIssueThreshold, 2) + .print().conclude(ortConfig.severeIssueThreshold, ORT_FAILURE_STATUS_CODE) } private fun runScanners( diff --git a/utils/ort/src/main/kotlin/Constants.kt b/utils/ort/src/main/kotlin/Constants.kt index 12637b8b11a71..756cf89902c2c 100644 --- a/utils/ort/src/main/kotlin/Constants.kt +++ b/utils/ort/src/main/kotlin/Constants.kt @@ -108,3 +108,9 @@ const val ORT_EVALUATOR_RULES_FILENAME = "evaluator.rules.kts" * The name of the ORT notifier script. */ const val ORT_NOTIFIER_SCRIPT_FILENAME = "notifier.notifications.kts" + +/** + * The minimum status code ORT CLI commands return on exit for failures (like rule violations), not errors (like + * existing output files). + */ +const val ORT_FAILURE_STATUS_CODE = 2