From a4d25ec999adb1d5914d37cf19fe3d5aafd6f5c7 Mon Sep 17 00:00:00 2001 From: Joel von der Weid <joel.von-der-weid@hesge.ch> Date: Wed, 3 Jul 2024 09:49:55 +0200 Subject: [PATCH] Add allowSonarFailure --- helpers/Dojo/AssignmentValidator.ts | 13 +++++++++---- models/Assignment.ts | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/helpers/Dojo/AssignmentValidator.ts b/helpers/Dojo/AssignmentValidator.ts index a7c783b..c6716fb 100644 --- a/helpers/Dojo/AssignmentValidator.ts +++ b/helpers/Dojo/AssignmentValidator.ts @@ -314,12 +314,17 @@ class AssignmentValidator { const runSuccess = SonarAnalyzer.runAnalysis(this.assignment.sonarKey, this.assignment.language, this.assignmentFile.buildLine); if ( runSuccess ) { - this.emitError(`Sonar gate failed`, 'Sonar analysis failure', AssignmentCheckerError.SONAR_ANALYSIS_FAILED); - throw new Error(); + if ( !this.assignment.allowSonarFailure ) { + this.emitError(`Sonar gate failed`, 'Sonar analysis failure', AssignmentCheckerError.SONAR_ANALYSIS_FAILED); + return; + } else { + this.endSubStep('Sonar gate failed, you should check the sonar project', false); + } + } else { + this.endSubStep('Sonar gate passed', false); } - this.endSubStep('Sonar gate passed', false); - this.endStep('Sonar analysis success', false); + this.endStep('Sonar analysis finished', false); } } diff --git a/models/Assignment.ts b/models/Assignment.ts index 6a24b32..9a9a6e8 100644 --- a/models/Assignment.ts +++ b/models/Assignment.ts @@ -13,6 +13,7 @@ interface Assignment { gitlabLastInfoDate: string; published: boolean; useSonar: boolean; + allowSonarFailure: boolean; sonarKey: string; sonarCreationInfo: SonarProjectCreation; language: Language; -- GitLab