diff --git a/build/jenkins/pipeline b/build/jenkins/pipeline index 3f9047a..b2c6e5c 100644 --- a/build/jenkins/pipeline +++ b/build/jenkins/pipeline @@ -24,9 +24,11 @@ pipeline { // Inno Setup Compiler path INNO_SETUP_PATH = "C:/Program Files (x86)/Inno Setup 6" // Path where Inno Setup is installed + // 7-Zip path (assuming default installation) + SEVEN_ZIP_PATH = "C:/Program Files/7-Zip" // Adjust if 7-Zip is installed elsewhere - // Set the PATH environment variable combining CUDA, cuDNN (if applicable), and Inno Setup paths - PATH = "${INNO_SETUP_PATH};${CUDA_PATH}/bin;${CUDNN_INCLUDE_DIR};${CUDNN_LIB_DIR};${env.PATH}" // Add Inno Setup, CUDA, and cuDNN to PATH + // Set the PATH environment variable combining CUDA, cuDNN (if applicable), Inno Setup, and 7-Zip paths + PATH = "${SEVEN_ZIP_PATH};${INNO_SETUP_PATH};${CUDA_PATH}/bin;${CUDNN_INCLUDE_DIR};${CUDNN_LIB_DIR};${env.PATH}" // Add 7-Zip, Inno Setup, CUDA, and cuDNN to PATH } stages { @@ -70,19 +72,95 @@ pipeline { stage('Run publish.cmd') { steps { // Run publish.cmd in the suite\build directory + // Assuming this script places the build artifacts (.exe and .bin files) + // into the 'suite' directory or a subdirectory within it. bat 'suite\\build\\publish.cmd' } } + stage('Archive Build Artifacts (7-Zip)') { + steps { + script { + echo "Starting 'Archive Build Artifacts (7-Zip)' stage." + def artifactsDirectory = 'suite' // Directory containing the build artifacts relative to workspace + def version = '1.0.0' // Default version + def filesToArchive = [] + def exeFound = false + + dir(artifactsDirectory) { + // Find all relevant files + def foundFiles = findFiles(glob: 'AzaionSuite*.exe') + findFiles(glob: 'AzaionSuite*.bin') + filesToArchive = foundFiles.collect { it.path } // Get list of paths + + // --- Version Extraction (only from .exe if present) --- + def exeFiles = findFiles(glob: 'AzaionSuite*.exe') + if (exeFiles.size() > 0) { + exeFound = true + def exeFilePath = exeFiles[0].path // Use path from the first found exe + // Regex to find version like 1.2.3 or 1.2.3-4 followed by .exe + def matcher = (exeFilePath =~ /AzaionSuite(\d+\.\d+\.\d+(-\d+)?)\.exe/) + if (matcher.find()) { + version = matcher.group(1) + echo "Found version for archive: ${version}" + } else { + echo "Warning: Could not extract version from '${exeFiles[0].name}'. Using default: ${version}" + } + } else { + echo "Warning: No executable found to extract version for archive. Using default: ${version}" + } + + // --- Zipping Logic --- + if (filesToArchive.size() > 0) { + // Get current date and time in YYYYMMDD-HHMMSS format using PowerShell + def timestamp = bat( + script: 'powershell -Command "Get-Date -Format YYYYMMdd-HHmmss"', + returnStdout: true + ).trim() // Trim to remove potential newline characters + + def zipFilename = "AzaionSuite.${version}-${timestamp}.zip" + // 7-Zip command requires quoting paths with spaces + def filesListString = filesToArchive.collect { "\"${it}\"" }.join(' ') // Quote each file path and join + + echo "Creating zip archive: ${zipFilename} using 7-Zip." + echo "Files to include: ${filesListString}" + + // Use 7z command to create a zip archive + // a: Add files to archive + // -tzip: Specify zip format + // Note: Requires 7-Zip to be installed and 7z.exe in the PATH + bat """ + @echo off + echo Zipping files with 7-Zip... + 7z a -tzip "${zipFilename}" ${filesListString} + if %errorlevel% neq 0 ( + echo Error creating zip archive with 7-Zip. 7z exit code: %errorlevel% + exit /b %errorlevel% + ) + echo Zip archive created successfully by 7-Zip. + """ + + // Archive the created zip file using Jenkins built-in step + archiveArtifacts artifacts: "${zipFilename}", fingerprint: true + echo "Archive step completed." + + } else { + echo "No files (.exe or .bin) found in '${artifactsDirectory}' to archive." + } + } + } + } + } + + stage('Deploy to Nexus RAW') { steps { script { echo "Starting 'Deploy to Nexus RAW' stage." - def targetDirectory = 'C:/Jenkins/workspace/AzaionSuite/suite' + def targetDirectory = 'C:/Jenkins/workspace/AzaionSuite/suite' // Assuming this is the workspace path on the agent def version = '1.0.0' // Default version def filesToUpload = [] - // Define the date formatter + // Define the date formatter (for folder name) def dateTimeFormat = new java.text.SimpleDateFormat("yyyyMMdd-HHmmss") dir(targetDirectory) { @@ -98,12 +176,12 @@ pipeline { def matcher = (exeFilePath =~ /AzaionSuite(\d+\.\d+\.\d+(-\d+)?)/) if (matcher.find()) { version = matcher.group(1) - echo "Found version: ${version}" + echo "Found version for Nexus deployment: ${version}" } else { echo "Warning: Could not extract version from '${exeFiles[0].name}'. Using default: ${version}" } } else { - echo "Warning: No executable found to extract version. Using default: ${version}" + echo "Warning: No executable found to extract version for Nexus deployment. Using default: ${version}" } // --- Upload Logic --- @@ -125,7 +203,7 @@ pipeline { // Use bat step for Windows agent commands bat """ @echo off - echo Uploading ${filePath} to ${uploadUrl} + echo Uploading "${filePath}" to "${uploadUrl}" curl -v -f -X PUT -u "${NEXUS_USER}:${NEXUS_PASSWORD}" --upload-file "${filePath}" "${uploadUrl}" if %errorlevel% neq 0 ( echo Error uploading ${fileName}. Curl exit code: %errorlevel%