Jenkins Test #9

This commit is contained in:
2025-10-08 18:00:12 +02:00
parent 871d7c8265
commit 9da4a5e852

95
Jenkinsfile vendored
View File

@@ -1,6 +1,12 @@
pipeline { pipeline {
agent { label 'windows' } agent { label 'windows' }
// 1. Déclare ici tes paramètres
parameters {
string(name: 'DISCORD_USER_ID', defaultValue: '378262266723696651', description: 'ID Discord pour les DMs')
choice(name: 'BUILD_TYPE', choices: ['Both', 'Debug', 'Release'], description: 'Type de build à lancer')
}
options { options {
timestamps() timestamps()
disableConcurrentBuilds() disableConcurrentBuilds()
@@ -19,31 +25,22 @@ pipeline {
} }
stage('Build') { stage('Build') {
when {
expression { params.BUILD_TYPE in ['Both','Debug'] }
}
parallel { parallel {
stage('Build Debug') { stage('Build Debug') {
when { expression { params.BUILD_TYPE in ['Both','Debug'] } }
steps { steps {
echo 'Building Debug...' echo 'Building Debug...'
bat """ bat '"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe" "%WORKSPACE%\\KhaoticEngineReborn.sln" /p:Configuration=Debug /p:Platform=x64 /m /verbosity:minimal'
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe" ^
"%WORKSPACE%\\KhaoticEngineReborn.sln" ^
/p:Configuration=Debug ^
/p:Platform=x64 ^
/m ^
/verbosity:minimal
"""
} }
} }
stage('Build Release') { stage('Build Release') {
when { expression { params.BUILD_TYPE in ['Both','Release'] } }
steps { steps {
echo 'Building Release...' echo 'Building Release...'
bat """ bat '"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe" "%WORKSPACE%\\KhaoticEngineReborn.sln" /p:Configuration=Release /p:Platform=x64 /m /verbosity:minimal'
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\MSBuild\\Current\\Bin\\MSBuild.exe" ^
"%WORKSPACE%\\KhaoticEngineReborn.sln" ^
/p:Configuration=Release ^
/p:Platform=x64 ^
/m ^
/verbosity:minimal
"""
} }
} }
} }
@@ -52,21 +49,19 @@ pipeline {
stage('Package') { stage('Package') {
parallel { parallel {
stage('Package Debug') { stage('Package Debug') {
when { expression { params.BUILD_TYPE in ['Both','Debug'] } }
steps { steps {
echo 'Packaging Debug into ZIP' echo 'Packaging Debug into ZIP'
bat 'if not exist "%WORKSPACE%\\builds" mkdir "%WORKSPACE%\\builds"' bat 'if not exist "%WORKSPACE%\\builds" mkdir "%WORKSPACE%\\builds"'
bat """ bat 'powershell -Command "Compress-Archive -Path ''%WORKSPACE%\\**\\Debug\\*'' -DestinationPath ''%WORKSPACE%\\builds\\KhaoticEngineReborn_Debug.zip'' -Force"'
powershell -Command "Compress-Archive -Path '%WORKSPACE%\\**\\Debug\\*' -DestinationPath '%WORKSPACE%\\builds\\KhaoticEngineReborn_Debug.zip' -Force"
"""
} }
} }
stage('Package Release') { stage('Package Release') {
when { expression { params.BUILD_TYPE in ['Both','Release'] } }
steps { steps {
echo 'Packaging Release into ZIP' echo 'Packaging Release into ZIP'
bat 'if not exist "%WORKSPACE%\\builds" mkdir "%WORKSPACE%\\builds"' bat 'if not exist "%WORKSPACE%\\builds" mkdir "%WORKSPACE%\\builds"'
bat """ bat 'powershell -Command "Compress-Archive -Path ''%WORKSPACE%\\**\\Release\\*'' -DestinationPath ''%WORKSPACE%\\builds\\KhaoticEngineReborn_Release.zip'' -Force"'
powershell -Command "Compress-Archive -Path '%WORKSPACE%\\**\\Release\\*' -DestinationPath '%WORKSPACE%\\builds\\KhaoticEngineReborn_Release.zip' -Force"
"""
} }
} }
} }
@@ -80,29 +75,35 @@ pipeline {
} }
post { post {
success { success {
script { script {
def debugUrl = "${env.BUILD_URL}artifact/builds/KhaoticEngineReborn_Debug.zip" // Liste les URLs selon le type
def releaseUrl = "${env.BUILD_URL}artifact/builds/KhaoticEngineReborn_Release.zip" def urls = []
bat """ if (params.BUILD_TYPE in ['Both','Debug']) {
curl -X POST http://192.168.1.131:2500/ci-notify ^ urls << "${env.BUILD_URL}artifact/builds/KhaoticEngineReborn_Debug.zip"
-H "Content-Type: application/json" ^ }
-d "{\\"userId\\": \\"378262266723696651\\",\\"status\\": \\"success\\",\\"urls\\":[\\"${debugUrl}\\",\\"${releaseUrl}\\"]}" if (params.BUILD_TYPE in ['Both','Release']) {
""" urls << "${env.BUILD_URL}artifact/builds/KhaoticEngineReborn_Release.zip"
} }
} // Envoi via ton bot
failure { bat """
script { curl -X POST http://192.168.1.131:2500/ci-notify ^
bat """ -H "Content-Type: application/json" ^
curl -X POST http://192.168.1.131:2500/ci-notify ^ -d "{\\"userId\\": \\"${params.DISCORD_USER_ID}\\",\\"status\\": \\"success\\",\\"urls\\":${groovy.json.JsonOutput.toJson(urls)}}"
-H "Content-Type: application/json" ^ """
-d "{\\"userId\\": \\"378262266723696651\\",\\"status\\": \\"failure\\",\\"urls\\":[]}" }
""" }
} failure {
} script {
always { bat """
cleanWs(deleteDirs: true, disableDeferredWipeout: true, notFailBuild: true) 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)
}
}
} }