updating and testing ImageMatcher pipeline

This commit is contained in:
dzaitsev
2025-05-03 15:09:28 +03:00
parent 0153634166
commit 6d17632c23
2 changed files with 129 additions and 57 deletions
+2 -12
View File
@@ -46,24 +46,14 @@ pipeline {
}
}
// Optional: Archive ImageMatcher build artifacts if needed by Azaion Build
// stage('Archive ImageMatcher Artifacts') {
// steps {
// echo 'Archiving ImageMatcher artifacts...'
// // Path is relative to the current directory (which will be SHARED_WORKSPACE due to the outer dir)
// dir(env.SHARED_WORKSPACE) { // Ensure this also runs in the shared workspace
// archiveArtifacts artifacts: 'path/to/imagematcher/build/output/**' // Adjust path relative to SHARED_WORKSPACE
// }
// }
// }
}
post {
success {
echo 'ImageMatcher built successfully. Triggering Azaion Build pipeline...'
// Trigger the Azaion Build pipeline job upon success
// Replace 'Azaion Build' with the exact name of your Azaion Build Jenkins job
build job: 'Azaion Build',
// Replace 'AzaionBuild' with the exact name of your Azaion Build Jenkins job
build job: 'AzaionBuild',
wait: false // Set to true if you want ImageMatcher Build to wait for Azaion Build to finish
// You might pass parameters here if Azaion Build needs info from ImageMatcher
// Example: parameters: [ string(name: 'IMAGEMATCHER_BUILD_NUMBER', value: env.BUILD_NUMBER) ]
+108 -26
View File
@@ -1,3 +1,4 @@
// Add this into polling for 2 minutes ----- */2 * * * *
pipeline {
agent { label 'Win10-BuildMachine' }
@@ -7,72 +8,153 @@ pipeline {
}
environment {
REPO_ANNOTATOR_URL = 'https://github.com/azaion/annotator.git'
REPO_GPS_DENIED_URL = 'https://github.com/azaion/gps-denied.git'
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://<nexus-server>:8081'
nexusRepo = 'generic-hosted'
nexusCreds = 'nexus-credentials-id' // Jenkins credential ID for Nexus
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 {
//Suite
// Checkout Suite repo using SSH
sshagent(credentials: ['DZ-id']) {
checkout([
$class: 'GitSCM',
branches: [[name: '*/dev']],
userRemoteConfigs: [[
url: "${env.REPO_ANNOTATOR_URL}"
url: "${env.REPO_ANNOTATOR_URL}", // Use SSH URL
]],
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'suite']]
])
}
//GPS-Denied
// Checkout GPS-Denied repo using SSH
sshagent(credentials: ['DZ-id']) {
checkout([
$class: 'GitSCM',
branches: [[name: '*/image-matcher']],
userRemoteConfigs: [[
url: "${env.REPO_GPS_DENIED_URL}"
url: "${env.REPO_GPS_DENIED_URL}", // Use SSH URL
]],
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'gps-denied']]
])
}
}
}
}
stage('Compile Gps Denied') {
steps {
call "AzaionSuite\gps-denied\image-matcher\build.cmd"
// Run build.cmd in the gps-denied\image-matcher directory
bat 'gps-denied\\image-matcher\\build.cmd'
}
}
stage('Run publish.cmd') {
steps {
call "AzaionSuite\suite\build\publish.cmd"
// Run publish.cmd in the suite\build directory
bat 'suite\\build\\publish.cmd'
}
}
stage('Deploy to Nexus') {
stage('Deploy to Nexus RAW') {
steps {
script {
// Use Nexus Artifact Uploader in the pipeline
nexusArtifactUploader(
nexusUrl: nexusUrl,
credentialsId: nexusCreds,
repository: nexusRepo,
artifacts: [
[artifactId: 'myapp',
version: "${BUILD_NUMBER}",
file: "target/myapp-${BUILD_NUMBER}.zip", // Artifact path from the build
type: 'zip',
classifier: '',
extension: 'zip']
]
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
}
}