// Add this into polling for 2 minutes ----- */2 * * * * pipeline { agent { label 'Win10-BuildMachine' } tools { git 'Default' // your Git installation name dotnetsdk 'dotnet-sdk' // the .NET SDK tool you configured } environment { REPO_ANNOTATOR_URL = 'git@github.com:azaion/annotator.git' REPO_GPS_DENIED_URL = 'git@github.com:azaion/gps-denied.git' PROJECT_PATH = 'Azaion.Suite/suite/Azaion.Suite.csproj' CONFIGURATION = 'Release' nexusUrl = 'http://192.168.1.101:8081' nexusRepo = 'AzaionSuite' nexusCreds = 'a42c7b91-bf8e-4229-be4c-c7edf518dd50' // Jenkins credential ID for Nexus // CUDA environment variables CUDA_PATH = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2" // Path to CUDA Toolkit CUDNN_INCLUDE_DIR = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/include" // cuDNN include path (optional) CUDNN_LIB_DIR = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/lib/x64" // cuDNN library path (optional) // Inno Setup Compiler path INNO_SETUP_PATH = "C:/Program Files (x86)/Inno Setup 6" // Path where Inno Setup is installed // 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 } stages { stage('Checkout') { steps { // Checkout Suite repo using SSH sshagent(credentials: ['DZ-id']) { checkout([ $class: 'GitSCM', branches: [[name: '*/dev']], userRemoteConfigs: [[ url: "${env.REPO_ANNOTATOR_URL}", // Use SSH URL ]], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'suite']] ]) } // Checkout GPS-Denied repo using SSH sshagent(credentials: ['DZ-id']) { checkout([ $class: 'GitSCM', branches: [[name: '*/image-matcher']], userRemoteConfigs: [[ url: "${env.REPO_GPS_DENIED_URL}", // Use SSH URL ]], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'gps-denied']] ]) } } } stage('Compile Gps Denied') { steps { // Run build.cmd in the gps-denied\image-matcher directory bat 'gps-denied\\image-matcher\\build.cmd' } } stage('Run publish.cmd') { steps { // Run publish.cmd in the suite\build directory bat 'suite\\build\\publish.cmd' } } stage('Deploy to Nexus RAW') { steps { script { echo "Starting 'Deploy to Nexus RAW' stage." def targetDirectory = 'C:/Jenkins/workspace/AzaionSuite/suite' def version = '1.0.0' // Default version def filesToUpload = [] // Define the date formatter def dateTimeFormat = new java.text.SimpleDateFormat("yyyyMMdd-HHmmss") dir(targetDirectory) { // Find both exe and bin files (returns an array) def exeFiles = findFiles(glob: 'AzaionSuite*.exe') def binFiles = findFiles(glob: 'AzaionSuite*.bin') filesToUpload = exeFiles + binFiles // Combine arrays // --- Version Extraction (only from .exe if present) --- if (exeFiles.size() > 0) { 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 def matcher = (exeFilePath =~ /AzaionSuite(\d+\.\d+\.\d+(-\d+)?)/) if (matcher.find()) { version = matcher.group(1) echo "Found version: ${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}" } // --- Upload Logic --- if (filesToUpload.size() > 0) { def now = new Date() def buildDateTime = dateTimeFormat.format(now) // Format the current date def uploadFolderName = "AzaionSuite.${version}-${buildDateTime}" echo "Preparing to upload ${filesToUpload.size()} file(s) to Nexus folder: ${uploadFolderName}" withCredentials([usernamePassword(credentialsId: nexusCreds, usernameVariable: 'NEXUS_USER', passwordVariable: 'NEXUS_PASSWORD')]) { filesToUpload.each { file -> def fileName = file.getName() def filePath = file.path // file.path should give the full agent path def uploadUrl = "${nexusUrl}/repository/${nexusRepo}/${uploadFolderName}/${fileName}" echo "Uploading: ${fileName} to ${uploadUrl}" // Single log per file upload start // Use bat step for Windows agent commands bat """ @echo off 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% exit /b %errorlevel% ) """ } } } else { echo "No files to upload to Nexus." } } } } } } post { success { echo 'Build successful. Triggering Google Drive upload pipeline...' // Trigger the Google Drive upload pipeline // Replace 'YourGoogleDriveUploadPipelineName' with the actual name of your Google Drive upload pipeline job build job: 'GoogleDriveUpload' } failure { echo 'Build failed. Google Drive upload pipeline will not be triggered.' // Optional: Add other actions for failure, like sending notifications } // Optional: Add always, unstable, etc. blocks if needed } }