Skip to content
Snippets Groups Projects
Commit 4c7fb3d6 authored by michael.minelli's avatar michael.minelli
Browse files

Config => Move result folder name to pipeline result and add result folder

parent 01b918e5
No related branches found
No related tags found
No related merge requests found
import GitlabVisibility from '../shared/types/Gitlab/GitlabVisibility'; import GitlabVisibility from '../shared/types/Gitlab/GitlabVisibility';
import { Exercice } from '../types/DatabaseTypes';
import path from 'path';
import fs from 'fs';
class Config { class Config {
...@@ -23,7 +26,7 @@ class Config { ...@@ -23,7 +26,7 @@ class Config {
}; };
public exercice: { public exercice: {
maxSameName: number; resultsFolder: string; default: { description: string; visibility: string; }; maxSameName: number; resultsFolder: string, pipelineResultsFolder: string; default: { description: string; visibility: string; };
}; };
public readonly userPasswordLength: number; public readonly userPasswordLength: number;
...@@ -74,7 +77,8 @@ class Config { ...@@ -74,7 +77,8 @@ class Config {
this.exercice = { this.exercice = {
maxSameName : Number(process.env.EXERCICE_MAX_SAME_NAME || 0), maxSameName : Number(process.env.EXERCICE_MAX_SAME_NAME || 0),
resultsFolder: process.env.EXERCICE_RESULTS_FOLDER ?? '', //Do not use convertWithEnvVars() because it is used in the exercice creation and muste be interpreted at exercice runtime resultsFolder : process.env.EXERCICE_RESULTS_FOLDER?.convertWithEnvVars() ?? '',
pipelineResultsFolder: process.env.EXERCICE_PIPELINE_RESULTS_FOLDER ?? '', //Do not use convertWithEnvVars() because it is used in the exercice creation and muste be interpreted at exercice runtime
default : { default : {
description: process.env.EXERCICE_DEFAULT_DESCRIPTION?.convertWithEnvVars() ?? '', description: process.env.EXERCICE_DEFAULT_DESCRIPTION?.convertWithEnvVars() ?? '',
visibility : process.env.EXERCICE_DEFAULT_VISIBILITY || GitlabVisibility.PRIVATE visibility : process.env.EXERCICE_DEFAULT_VISIBILITY || GitlabVisibility.PRIVATE
...@@ -84,6 +88,14 @@ class Config { ...@@ -84,6 +88,14 @@ class Config {
this.userPasswordLength = Number(process.env.USER_PASSWORD_LENGTH || 0); this.userPasswordLength = Number(process.env.USER_PASSWORD_LENGTH || 0);
this.userPasswordSaltRounds = Number(process.env.USER_PASSWORD_SALT_ROUNDS || 10); this.userPasswordSaltRounds = Number(process.env.USER_PASSWORD_SALT_ROUNDS || 10);
} }
public getResultsFolder(exercice: Exercice): string {
const folderPath = path.join(this.exercice.resultsFolder, exercice.enonceName, exercice.id);
fs.mkdirSync(folderPath, { recursive: true });
return folderPath;
}
} }
......
...@@ -68,7 +68,7 @@ class ExerciceRoutes implements RoutesManager { ...@@ -68,7 +68,7 @@ class ExerciceRoutes implements RoutesManager {
await GitlabManager.addRepositoryVariable(repository.id, 'DOJO_EXERCICE_ID', exerciceId, false, true); await GitlabManager.addRepositoryVariable(repository.id, 'DOJO_EXERCICE_ID', exerciceId, false, true);
await GitlabManager.addRepositoryVariable(repository.id, 'DOJO_SECRET', secret, false, true); await GitlabManager.addRepositoryVariable(repository.id, 'DOJO_SECRET', secret, false, true);
await GitlabManager.addRepositoryVariable(repository.id, 'DOJO_RESULTS_FOLDER', Config.exercice.resultsFolder, false, false); await GitlabManager.addRepositoryVariable(repository.id, 'DOJO_RESULTS_FOLDER', Config.exercice.pipelineResultsFolder, false, false);
break; break;
} catch ( error ) { } catch ( error ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment