Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • Dojo_Project_Nguyen/backend/dojobackendapi
  • dojo_project/projects/backend/dojobackendapi
2 results
Select Git revision
Show changes
Commits on Source (2)
Subproject commit fec06e6aeeff2083bfe82b38182f6a02c73d023f
Subproject commit 57997f6ff4ad2d2e23e03f86d997f64463cc898d
###################################################################################################################
# DO NOT MODIFY THIS FILE
# This file is the ci/cd pipeline that will be used to test your exercice
###################################################################################################################
variables:
GIT_SUBMODULE_STRATEGY: recursive
GIT_SUBMODULE_FORCE_HTTPS: "true"
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR:
DOCKER_DRIVER: overlay2
stages:
- dojo
dojo:
stage: dojo
tags:
- dojo_exercice
services:
- docker:dind
image:
name: dojohesso/dojo_exercice_checker:latest
script:
- dojo_exercice_checker
artifacts:
when: always
paths:
- $DOJO_RESULTS_FOLDER/*
allow_failure: false
\ No newline at end of file
......@@ -186,6 +186,17 @@ class GitlabManager {
return response.data;
}
async createFile(repoId: number, filePath: string, fileBase64: string, commitMessage: string, branch: string = 'main', authorName: string = 'Dojo', authorMail: string | undefined = undefined) {
await axios.post(this.getApiUrl(GitlabRoutes.REPOSITORY_FILE).replace('{{id}}', String(repoId)).replace('{{filePath}}', encodeURIComponent(filePath)), {
encoding : 'base64',
branch : branch,
commit_message: commitMessage,
content : fileBase64,
author_name : authorName,
author_email : authorMail
});
}
}
......
......@@ -120,6 +120,18 @@ class ExerciceRoutes implements RoutesManager {
return res.status(StatusCodes.INSUFFICIENT_SPACE_ON_RESOURCE).send();
}
try {
await GitlabManager.createFile(repository.id, '.gitlab-ci.yml', fs.readFileSync(path.join(__dirname, '../../assets/exercice_gitlab_ci.yml'), 'base64'), 'Add .gitlab-ci.yml (DO NOT MODIFY THIS FILE)');
} catch ( error ) {
logger.error(error);
if ( error instanceof AxiosError ) {
return res.status(error.response?.status ?? HttpStatusCode.InternalServerError).send();
}
return res.status(StatusCodes.INTERNAL_SERVER_ERROR).send();
}
try {
await Promise.all([ ...new Set([ ...enonce.staff.map(user => user.gitlabId), ...params.members.map(member => member.id) ]) ].map(async (memberId: number): Promise<GitlabMember | false> => {
try {
......@@ -158,11 +170,12 @@ class ExerciceRoutes implements RoutesManager {
return req.session.sendResponse(res, StatusCodes.OK, exercice);
} catch ( error ) {
logger.error(error);
if ( error instanceof AxiosError ) {
return res.status(error.response?.status ?? HttpStatusCode.InternalServerError).send();
}
logger.error(error);
return res.status(StatusCodes.INTERNAL_SERVER_ERROR).send();
}
}
......