Skip to content
Snippets Groups Projects
Commit e5a95e80 authored by joel.vonderwe's avatar joel.vonderwe Committed by michael.minelli
Browse files

Test sonar qualities before creating assignment

parent dfe11ad2
No related branches found
No related tags found
No related merge requests found
......@@ -86,6 +86,20 @@ class AssignmentCreateCommand extends CommanderCommand {
}
languagesSpinner.succeed(`Language "${ options.language }" is supported`);
if ( (this.sonarGate ?? '') !== '' || this.sonarProfiles.length > 0 ) {
const qualitiesSpinner: ora.Ora = ora('Checking sonar qualities').start();
// SonarQube quality gate and profiles
const result = await DojoBackendManager.testSonarQualities(this.sonarGate ?? '', this.sonarProfiles);
if ( !result.valid ) {
const invalid = (result.badGate == undefined ? result.badProfiles : [ result.badGate, ...result.badProfiles ]);
qualitiesSpinner.fail(`Invalid quality gate or profiles : ${ invalid }`);
throw new Error();
}
qualitiesSpinner.succeed(`Quality gate and profiles are valid`);
}
// SonarQube languages
if ( this.sonar ) {
const sonarLang = await DojoBackendManager.getSonarLanguages();
......
......@@ -393,6 +393,15 @@ class DojoBackendManager {
return resp.data.data;
}
public async testSonarQualities(gate: string, profiles: string[]) {
const resp = await axios.post<DojoBackendResponse<{ valid: boolean, badProfiles: string[], badGate: string | undefined }>>(
this.getApiUrl(ApiRoute.SONAR_QUALITIES), {
gate: gate,
profiles: profiles,
});
return resp.data.data;
}
public async createTag(name: string, type: string, verbose: boolean = true): Promise<Tag | undefined> {
const spinner: ora.Ora = ora('Creating tag...');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment