From a2dc31f49c86c157dd686347964333a5d8b5709b Mon Sep 17 00:00:00 2001 From: CatChow0 Date: Wed, 8 Oct 2025 18:23:09 +0200 Subject: [PATCH] Jenkins Test #15 --- Jenkinsfile | 93 +++++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 25d0c6b..378e7be 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -53,27 +53,26 @@ pipeline { when { expression { params.BUILD_TYPE in ['Both','Debug'] } } steps { powershell """ - if (-Not (Test-Path \"${env.WORKSPACE}\\builds\")) { - New-Item -ItemType Directory -Path \"${env.WORKSPACE}\\builds\" | Out-Null - } - Compress-Archive -Path \"${env.WORKSPACE}\\**\\Debug\\*\" ` - -DestinationPath \"${env.WORKSPACE}\\builds\\KhaoticEngineReborn_Debug.zip\" ` - -Force - """ - + if (-Not (Test-Path \"${env.WORKSPACE}\\builds\")) { + New-Item -ItemType Directory -Path \"${env.WORKSPACE}\\builds\" | Out-Null + } + Compress-Archive -Path \"${env.WORKSPACE}\\**\\Debug\\*\" ` + -DestinationPath \"${env.WORKSPACE}\\builds\\KhaoticEngineReborn_Debug.zip\" ` + -Force + """ } } stage('Package Release') { when { expression { params.BUILD_TYPE in ['Both','Release'] } } steps { powershell """ - if (-Not (Test-Path \"${env.WORKSPACE}\\builds\")) { - New-Item -ItemType Directory -Path \"${env.WORKSPACE}\\builds\" | Out-Null - } - Compress-Archive -Path \"${env.WORKSPACE}\\**\\Release\\*\" ` - -DestinationPath \"${env.WORKSPACE}\\builds\\KhaoticEngineReborn_Release.zip\" ` - -Force - """ + if (-Not (Test-Path \"${env.WORKSPACE}\\builds\")) { + New-Item -ItemType Directory -Path \"${env.WORKSPACE}\\builds\" | Out-Null + } + Compress-Archive -Path \"${env.WORKSPACE}\\**\\Release\\*\" ` + -DestinationPath \"${env.WORKSPACE}\\builds\\KhaoticEngineReborn_Release.zip\" ` + -Force + """ } } } @@ -87,35 +86,37 @@ pipeline { } post { - success { - script { - // Prépare la liste d'URL brutes - def urlsList = [] - if (params.BUILD_TYPE in ['Both','Debug']) { - urlsList << "${env.BUILD_URL}artifact/builds/KhaoticEngineReborn_Debug.zip" - } - if (params.BUILD_TYPE in ['Both','Release']) { - urlsList << "${env.BUILD_URL}artifact/builds/KhaoticEngineReborn_Release.zip" - } - // Fabrication manuelle d'un JSON array de strings - def urlsJson = urlsList.collect { "\"${it}\"" }.join(',' ) - urlsJson = "[${urlsJson}]" + success { + script { + def urls = [] + if (params.BUILD_TYPE in ['Both','Debug']) { + urls << "${env.BUILD_URL}artifact/builds/KhaoticEngineReborn_Debug.zip" + } + if (params.BUILD_TYPE in ['Both','Release']) { + urls << "${env.BUILD_URL}artifact/builds/KhaoticEngineReborn_Release.zip" + } + // Construire le JSON correct pour l'envoi + def urlsJson = urls.collect { "\"${it}\"" }.join(',') + urlsJson = "[${urlsJson}]" - bat """ - curl -X POST http://192.168.1.131:2500/ci-notify ^ - -H "Content-Type: application/json" ^ - -d "{\\"userId\\":\\"${params.DISCORD_USER_ID}\\",\\"status\\":\\"success\\",\\"urls\\":${urlsJson}}" - """ - } - } - failure { - script { - bat """ - curl -X POST http://192.168.1.131:2500/ci-notify ^ - -H "Content-Type: application/json" ^ - -d "{\\"userId\\":\\"${params.DISCORD_USER_ID}\\",\\"status\\":\\"failure\\",\\"urls\\":[]}" - """ - } - } - } -} \ No newline at end of file + bat """ + curl -X POST http://192.168.1.131:2500/ci-notify ^ + -H "Content-Type: application/json" ^ + -d "{\\"userId\\":\\"${params.DISCORD_USER_ID}\\",\\"status\\":\\"success\\",\\"urls\\":${urlsJson}}" + """ + } + } + failure { + script { + bat """ + curl -X POST http://192.168.1.131:2500/ci-notify ^ + -H "Content-Type: application/json" ^ + -d "{\\"userId\\":\\"${params.DISCORD_USER_ID}\\",\\"status\\":\\"failure\\",\\"urls\\":[]}" + """ + } + } + always { + cleanWs(deleteDirs: true, disableDeferredWipeout: true, notFailBuild: true) + } + } +}