Files
khaotic-engine-Reborn/Jenkinsfile
2025-10-08 18:17:33 +02:00

121 lines
4.1 KiB
Groovy

pipeline {
agent { label 'windows' }
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 {
timestamps()
disableConcurrentBuilds()
timeout(time: 30, unit: 'MINUTES')
}
triggers {
pollSCM('')
}
stages {
stage('Checkout') {
steps { checkout scm }
}
stage('Build') {
when { expression { params.BUILD_TYPE in ['Both','Debug','Release'] } }
parallel {
stage('Build Debug') {
when { expression { params.BUILD_TYPE in ['Both','Debug'] } }
steps {
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
"""
}
}
stage('Build Release') {
when { expression { params.BUILD_TYPE in ['Both','Release'] } }
steps {
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
"""
}
}
}
}
stage('Package') {
parallel {
stage('Package Debug') {
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
"""
}
}
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
"""
}
}
}
}
stage('Archive Artifacts') {
steps {
archiveArtifacts artifacts: 'builds/*.zip', fingerprint: true
}
}
}
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}]"
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\\":[]}"
"""
}
}
}
}