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

Assignment => Bug fix on creation: If the CI/CD file was already in the...

Assignment => Bug fix on creation: If the CI/CD file was already in the template repo, the assignment creation failed
parent 723ea8bb
No related branches found
No related tags found
No related merge requests found
Pipeline #28320 passed
openapi: 3.1.0
info:
title: Dojo API
version: 3.2.0
version: 3.3.0
description: |
**Backend API of the Dojo project.**
......
......@@ -241,6 +241,18 @@ class GitlabManager {
async updateFile(repoId: number, filePath: string, fileBase64: string, commitMessage: string, branch: string = 'main', authorName: string = 'Dojo', authorMail: string | undefined = undefined) {
return this.createUpdateFile(false, repoId, filePath, fileBase64, commitMessage, branch, authorName, authorMail);
}
async deleteFile(repoId: number, filePath: string, commitMessage: string, branch: string = 'main', authorName: string = 'Dojo', authorMail: string | undefined = undefined) {
await axios.delete(this.getApiUrl(GitlabRoute.REPOSITORY_FILE).replace('{{id}}', String(repoId)).replace('{{filePath}}', encodeURIComponent(filePath)), {
data: {
branch : branch,
commit_message: commitMessage,
author_name : authorName,
author_email : authorMail
}
});
}
}
......
......@@ -120,6 +120,10 @@ class AssignmentRoutes implements RoutesManager {
return GlobalHelper.repositoryCreationError('Repo params error', error, req, res, DojoStatusCode.ASSIGNMENT_CREATION_GITLAB_ERROR, DojoStatusCode.ASSIGNMENT_CREATION_INTERNAL_ERROR, repository);
}
try {
await GitlabManager.deleteFile(repository.id, '.gitlab-ci.yml', 'Remove .gitlab-ci.yml');
} catch ( error ) { /* empty */ }
try {
await GitlabManager.createFile(repository.id, '.gitlab-ci.yml', fs.readFileSync(path.join(__dirname, '../../assets/assignment_gitlab_ci.yml'), 'base64'), 'Add .gitlab-ci.yml (DO NOT MODIFY THIS FILE)');
} catch ( error ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment