From d9e998d2ff35200faa6f17d818d45db5db2e2459 Mon Sep 17 00:00:00 2001 From: Luc SORIGNET Date: Mon, 9 Feb 2026 12:15:51 +0100 Subject: [PATCH 1/6] chore: modification de la ci --- JenkinsFile | 85 ----------------------- ci/build.Jenkinsfile | 91 +++++++++++++++++++++++++ ci/deploy.Jenkinsfile | 42 ++++++++++++ {ci-script => ci/scripts}/makeDocker.sh | 28 ++++---- 4 files changed, 149 insertions(+), 97 deletions(-) delete mode 100644 JenkinsFile create mode 100644 ci/build.Jenkinsfile create mode 100644 ci/deploy.Jenkinsfile rename {ci-script => ci/scripts}/makeDocker.sh (59%) diff --git a/JenkinsFile b/JenkinsFile deleted file mode 100644 index 94ac35e..0000000 --- a/JenkinsFile +++ /dev/null @@ -1,85 +0,0 @@ -pipeline { - agent any - - environment { - DOCKER_REGISTRY = 'git.v0id.ovh' - ORGANIZATION = "n3wt-innov" - APP_NAME = 'n3wt-school' - } - - // Déclencher uniquement sur les tags - triggers { - issueCommentTrigger('.*deploy.*') - } - - stages { - stage('Vérification du Tag') { - when { - expression { env.TAG_NAME != null } - } - steps { - script { - // Extraire la version du tag - env.VERSION = env.TAG_NAME - echo "Version détectée: ${env.VERSION}" - } - } - } - - stage('Build Docker Images') { - when { - expression { env.TAG_NAME != null } - } - steps { - script { - // Donner les permissions d'exécution au script - sh 'chmod +x ./ci-scripts/makeDocker.sh' - - // Exécuter le script avec la version - sh """ - ./ci-scripts/makeDocker.sh ${env.VERSION} - """ - } - } - } - - stage('Push sur Registry') { - when { - expression { env.TAG_NAME != null } - } - steps { - script { - withCredentials([usernamePassword( - credentialsId: 'docker-registry-credentials', - usernameVariable: 'REGISTRY_USER', - passwordVariable: 'REGISTRY_PASS' - )]) { - // Login au registry - sh "docker login ${DOCKER_REGISTRY} -u ${REGISTRY_USER} -p ${REGISTRY_PASS}" - - // Push des images - sh """ - docker push ${DOCKER_REGISTRY}/${ORGANIZATION}/${APP_NAME}/frontend:${env.VERSION} - docker push ${DOCKER_REGISTRY}/${ORGANIZATION}/${APP_NAME}/backend:${env.VERSION} - docker push ${DOCKER_REGISTRY}/${ORGANIZATION}/${APP_NAME}/frontend:latest - docker push ${DOCKER_REGISTRY}/${ORGANIZATION}/${APP_NAME}/backend:latest - """ - } - } - } - } - } - - post { - success { - echo "Build et push des images Docker réussis pour la version ${env.VERSION}" - } - failure { - echo "Échec du build ou du push des images Docker" - } - always { - // Nettoyage - sh 'docker system prune -f' - } - } -} \ No newline at end of file diff --git a/ci/build.Jenkinsfile b/ci/build.Jenkinsfile new file mode 100644 index 0000000..7a5da2e --- /dev/null +++ b/ci/build.Jenkinsfile @@ -0,0 +1,91 @@ +pipeline { + + agent { + label "SLAVE-N3WT" + } + + options { + disableConcurrentBuilds() + timestamps() + } + + environment { + DOCKER_REGISTRY = "git.v0id.ovh" + ORG_NAME = "n3wt-innov" + APP_NAME = "n3wt-school" + + IMAGE_FRONT = "${DOCKER_REGISTRY}/${ORG_NAME}/${APP_NAME}/frontend" + IMAGE_BACK = "${DOCKER_REGISTRY}/${ORG_NAME}/${APP_NAME}/backend" + } + + stages { + + stage("Clean Workspace") { + steps { + cleanWs() + } + } + + stage("Only Tags Build") { + when { + buildingTag() + } + steps { + echo "Build déclenché par tag : ${TAG_NAME}" + } + } + + stage("Build Docker Images") { + when { + buildingTag() + } + steps { + sh """ + chmod +x ./ci/scripts/makeDocker.sh + ./ci/scripts/makeDocker.sh ${TAG_NAME} + """ + } + } + + stage("Push Images to Registry") { + when { + buildingTag() + } + steps { + withCredentials([usernamePassword( + credentialsId: "gitea-jenkins", + usernameVariable: "REGISTRY_USER", + passwordVariable: "REGISTRY_PASS" + )]) { + + sh """ + echo "Login registry..." + docker login ${DOCKER_REGISTRY} \ + -u ${REGISTRY_USER} \ + -p ${REGISTRY_PASS} + + echo "Push version images..." + docker push ${IMAGE_FRONT}:${TAG_NAME} + docker push ${IMAGE_BACK}:${TAG_NAME} + + echo "Tag latest..." + docker tag ${IMAGE_FRONT}:${TAG_NAME} ${IMAGE_FRONT}:latest + docker tag ${IMAGE_BACK}:${TAG_NAME} ${IMAGE_BACK}:latest + + docker push ${IMAGE_FRONT}:latest + docker push ${IMAGE_BACK}:latest + """ + } + } + } + } + + post { + always { + sh """ + docker builder prune -f + docker image prune -f + """ + } + } +} diff --git a/ci/deploy.Jenkinsfile b/ci/deploy.Jenkinsfile new file mode 100644 index 0000000..022e9c7 --- /dev/null +++ b/ci/deploy.Jenkinsfile @@ -0,0 +1,42 @@ +pipeline { + agent { label "SLAVE-N3WT" } + + parameters { + choice(name: 'ENVIRONMENT', choices: ['demo', 'prod'], description: 'Choisir environnement') + string(name: 'VERSION', defaultValue: 'v1.0.0', description: 'Version Docker à déployer') + } + + environment { + PLATEFORME_DEMO = 'demo.n3wtschool.com' + PLATEFORME_PROD = 'vps.n3wtschool.com' + DEPLOY_DIR = '~/n3wtschool' + } + + stages { + stage('Deploy') { + steps { + script { + def targetHost = params.ENVIRONMENT == 'prod' ? env.PLATEFORME_PROD : env.PLATEFORME_DEMO + def deployDir = env.DEPLOY_DIR + + // Le credential id Jenkins qui contient la clé SSH + def sshCredentialId = params.ENVIRONMENT == 'prod' ? 'vps_n3wt_prod' : 'demo_n3wt' + + // Le user SSH que tu passes dans la commande ssh + def sshUser = params.ENVIRONMENT == 'prod' ? 'root' : 'demo' + + sshagent([sshCredentialId]) { + sh """ + ssh -o StrictHostKeyChecking=no ${sshUser}@${targetHost} <" exit 1 fi -SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd $SCRIPT_PATH + # Configuration DOCKER_REGISTRY="git.v0id.ovh" +ORG_NAME="n3wt-innov" APP_NAME="n3wt-school" echo "Début de la construction des images Docker pour la version ${VERSION}" # Construction de l'image Frontend echo "Construction de l'image Frontend..." -cd ../Front-End +cd $SCRIPT_PATH/../../Front-End + docker build \ --build-arg BUILD_MODE=production \ - -t ${DOCKER_REGISTRY}/n3wt-innov/${APP_NAME}/frontend:${VERSION} \ - -t ${DOCKER_REGISTRY}/n3wt-innov/${APP_NAME}/frontend:latest \ + -t ${DOCKER_REGISTRY}/${ORG_NAME}/${APP_NAME}/frontend:${VERSION} \ + -t ${DOCKER_REGISTRY}/${ORG_NAME}/${APP_NAME}/frontend:latest \ . if [ $? -ne 0 ]; then @@ -32,10 +36,10 @@ fi # Construction de l'image Backend echo "Construction de l'image Backend..." -cd ../Back-End +cd $SCRIPT_PATH/../../Back-End docker build \ - -t ${DOCKER_REGISTRY}/n3wt-innov/${APP_NAME}/backend:${VERSION} \ - -t ${DOCKER_REGISTRY}/n3wt-innov/${APP_NAME}/backend:latest \ + -t ${DOCKER_REGISTRY}/${ORG_NAME}/${APP_NAME}/backend:${VERSION} \ + -t ${DOCKER_REGISTRY}/${ORG_NAME}/${APP_NAME}/backend:latest \ . if [ $? -ne 0 ]; then @@ -45,9 +49,9 @@ fi echo "Construction des images Docker terminée avec succès" echo "Images créées :" -echo "- ${DOCKER_REGISTRY}/${APP_NAME}/frontend:${VERSION}" -echo "- ${DOCKER_REGISTRY}/${APP_NAME}/frontend:latest" -echo "- ${DOCKER_REGISTRY}/${APP_NAME}/backend:${VERSION}" -echo "- ${DOCKER_REGISTRY}/${APP_NAME}/backend:latest" +echo "- ${DOCKER_REGISTRY}/${ORG_NAME}/${APP_NAME}/frontend:${VERSION}" +echo "- ${DOCKER_REGISTRY}/${ORG_NAME}/${APP_NAME}/frontend:latest" +echo "- ${DOCKER_REGISTRY}/${ORG_NAME}/${APP_NAME}/backend:${VERSION}" +echo "- ${DOCKER_REGISTRY}/${ORG_NAME}/${APP_NAME}/backend:latest" exit 0 \ No newline at end of file From 61f63f9dc92683efe79453374eecea38fff7741f Mon Sep 17 00:00:00 2001 From: Luc SORIGNET Date: Mon, 9 Feb 2026 13:50:22 +0100 Subject: [PATCH 2/6] =?UTF-8?q?fix:=20remplace=20cleanWs=20par=20deleteDir?= =?UTF-8?q?=20(m=C3=A9thode=20native=20Jenkins)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ci/build.Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.Jenkinsfile b/ci/build.Jenkinsfile index 7a5da2e..4492619 100644 --- a/ci/build.Jenkinsfile +++ b/ci/build.Jenkinsfile @@ -22,7 +22,7 @@ pipeline { stage("Clean Workspace") { steps { - cleanWs() + deleteDir() } } From ace4dcbf07360605fbb2c9461cad3b39111ed123 Mon Sep 17 00:00:00 2001 From: Luc SORIGNET Date: Mon, 9 Feb 2026 13:54:13 +0100 Subject: [PATCH 3/6] fix: remplace les conditions de build --- ci/build.Jenkinsfile | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ci/build.Jenkinsfile b/ci/build.Jenkinsfile index 4492619..a016452 100644 --- a/ci/build.Jenkinsfile +++ b/ci/build.Jenkinsfile @@ -20,18 +20,26 @@ pipeline { stages { - stage("Clean Workspace") { + stage("Check Tag") { + when { + not { + buildingTag() + } + } steps { - deleteDir() + script { + currentBuild.result = 'NOT_BUILT' + error("⚠️ Pipeline uniquement déclenchée sur les tags. Aucun tag détecté.") + } } } - stage("Only Tags Build") { + stage("Clean Workspace") { when { buildingTag() } steps { - echo "Build déclenché par tag : ${TAG_NAME}" + deleteDir() } } From 856443d4ed7b2de79bebd9bc67ec909bc28938a4 Mon Sep 17 00:00:00 2001 From: Luc SORIGNET Date: Mon, 9 Feb 2026 14:15:36 +0100 Subject: [PATCH 4/6] fix: clean ws --- ci/build.Jenkinsfile | 9 --------- 1 file changed, 9 deletions(-) diff --git a/ci/build.Jenkinsfile b/ci/build.Jenkinsfile index a016452..d06f2b1 100644 --- a/ci/build.Jenkinsfile +++ b/ci/build.Jenkinsfile @@ -34,15 +34,6 @@ pipeline { } } - stage("Clean Workspace") { - when { - buildingTag() - } - steps { - deleteDir() - } - } - stage("Build Docker Images") { when { buildingTag() From 12a6ad1d616e09b55a90f16cc51828585cc5e48b Mon Sep 17 00:00:00 2001 From: Luc SORIGNET Date: Mon, 9 Feb 2026 14:15:36 +0100 Subject: [PATCH 5/6] fix: clean ws --- Back-End/__version__.py | 2 +- Front-End/package.json | 4 ++-- ci/build.Jenkinsfile | 9 --------- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/Back-End/__version__.py b/Back-End/__version__.py index 27fdca4..81f0fde 100644 --- a/Back-End/__version__.py +++ b/Back-End/__version__.py @@ -1 +1 @@ -__version__ = "0.0.3" +__version__ = "0.0.4" diff --git a/Front-End/package.json b/Front-End/package.json index 335df53..e0c19e4 100644 --- a/Front-End/package.json +++ b/Front-End/package.json @@ -1,6 +1,6 @@ { "name": "n3wt-school-front-end", - "version": "0.0.3", + "version": "0.0.4", "private": true, "scripts": { "dev": "next dev", @@ -51,4 +51,4 @@ "postcss": "^8.4.47", "tailwindcss": "^3.4.14" } -} +} \ No newline at end of file diff --git a/ci/build.Jenkinsfile b/ci/build.Jenkinsfile index a016452..d06f2b1 100644 --- a/ci/build.Jenkinsfile +++ b/ci/build.Jenkinsfile @@ -34,15 +34,6 @@ pipeline { } } - stage("Clean Workspace") { - when { - buildingTag() - } - steps { - deleteDir() - } - } - stage("Build Docker Images") { when { buildingTag() From ff1d113698162ecf0c165116f5227723a81cfa16 Mon Sep 17 00:00:00 2001 From: Luc SORIGNET Date: Mon, 16 Feb 2026 16:10:22 +0100 Subject: [PATCH 6/6] docs: Mise en place du MO de MEP --- README.md | 27 ++++-------------------- docs/manuels/MEP/MO_PRE_MEP.md | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 23 deletions(-) create mode 100644 docs/manuels/MEP/MO_PRE_MEP.md diff --git a/README.md b/README.md index d29f1fc..3c40055 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Maquette figma : https://www.figma.com/design/1BtWHIQlJDTeue2oYblefV/Maquette-Lo Lien de téléchargement : https://www.docker.com/get-started/ -# Lancement de monteschool +# Lancement du projet ```sh docker compose up -d @@ -36,7 +36,7 @@ Lancement du front end npm run dev ``` -se connecter à localhost:8080 +- se connecter à localhost:8080 pour le backend localhost:3000 pour le front # Installation et développement en local @@ -57,25 +57,6 @@ npm i npm run format ``` -# Faire une livraison Mise en Production +# Mise en Production, Préparation de la release -```sh -# Faire la première release (1.0.0) -npm run release -- --first-release - -# Faire une prerelease (RC,alpha,beta) -npm run release -- --prerelease - - -# Faire une release -npm run release - -# Forcer la release sur un mode particulier (majeur, mineur ou patch) -# npm run script -npm run release -- --release-as minor -# Or -npm run release -- --release-as 1.1.0 - -# ignorer les hooks de commit lors de la release -npm run release -- --no-verify -``` +- [MO_PREPARATION_MISE_EN_PROD](./docs/MEP/MO_PRE_MEP.md) diff --git a/docs/manuels/MEP/MO_PRE_MEP.md b/docs/manuels/MEP/MO_PRE_MEP.md new file mode 100644 index 0000000..7249459 --- /dev/null +++ b/docs/manuels/MEP/MO_PRE_MEP.md @@ -0,0 +1,38 @@ +# Préparation de la RELEASE et du CHANGELOG + +- Vérifier que l'ensemble des tickets sont mergé dans develop +- Fusionner develop dans main via une [nouvelle demande d'ajout](https://git.v0id.ovh/n3wt-innov/n3wt-school/compare/main...develop) +- Faire une release avec la commande `npm run release` sur la branch main + \*\* NB: si vous souhaité avoir une release particulier (cf. Utilisation de standart-version) +- Pousser le commit de changement de version/Changelog et le tag sur main +- Depuis jenkins lancer le build sur le nouveau tag créé : https://jenkins.v0id.ovh/job/N3WT/job/Newt-Innov/job/n3wt-school/view/tags/ + +# Faire une Mise en Production + +- Depuis jenkins deployer la nouvelle version tagué. + +# Utilisation de standart-version + +L'utilisation de la norme conventionnal commit permet la génération automatique d'un CHANGELOG +via l'outil [standard-version](https://github.com/conventional-changelog/standard-version) + +```sh +# Faire la première release (1.0.0) +npm run release -- --first-release + +# Faire une prerelease (RC,alpha,beta) +npm run release -- --prerelease + + +# Faire une release +npm run release + +# Forcer la release sur un mode particulier (majeur, mineur ou patch) +# npm run script +npm run release -- --release-as minor +# Or +npm run release -- --release-as 1.1.0 + +# ignorer les hooks de commit lors de la release +npm run release -- --no-verify +```