updated zip and gdrive upload files.

This commit is contained in:
dzaitsev
2025-05-21 18:28:20 +03:00
parent f870198011
commit 39ed74996d
9 changed files with 123 additions and 790 deletions
+27
View File
@@ -0,0 +1,27 @@
Write-Output "`n=== Starting Upload: Full Installer ZIP ==="
$uploadFolder = "AzaionSuiteBuilds"
Write-Output "[INFO] Target Google Drive folder: $uploadFolder"
Write-Output "[INFO] Looking for latest .zip matching 'AzaionSuite.Full.*.zip'..."
$fullZip = Get-ChildItem -Path . -Filter "AzaionSuite.Full.*.zip" |
Sort-Object LastWriteTime -Descending |
Select-Object -First 1
if ($fullZip) {
Write-Output "[FOUND] Full installer ZIP: $($fullZip.Name)"
Write-Output "[INFO] Full path: $($fullZip.FullName)"
Write-Output "[ACTION] Uploading file to Google Drive using rclone..."
rclone copy "$($fullZip.FullName)" "AzaionGoogleDrive:$uploadFolder" --progress
if ($LASTEXITCODE -eq 0) {
Write-Output "[SUCCESS] ✅ Full installer ZIP uploaded successfully."
} else {
Write-Output "[ERROR] ❌ Upload failed with exit code $LASTEXITCODE."
}
} else {
Write-Output "[WARNING] ⚠️ No matching Full installer ZIP found in current directory."
}
Write-Output "=== Upload Complete: Full Installer ZIP ===`n"
+27
View File
@@ -0,0 +1,27 @@
Write-Output "`n=== Starting Upload: Iterative Installer ==="
$uploadFolder = "AzaionSuiteBuilds"
Write-Output "[INFO] Target Google Drive folder: $uploadFolder"
Write-Output "[INFO] Looking for latest .exe matching 'AzaionSuite.Iterative.*.exe'..."
$iterativeFile = Get-ChildItem -Path . -Filter "AzaionSuite.Iterative.*.exe" |
Sort-Object LastWriteTime -Descending |
Select-Object -First 1
if ($iterativeFile) {
Write-Output "[FOUND] Iterative installer: $($iterativeFile.Name)"
Write-Output "[INFO] Full path: $($iterativeFile.FullName)"
Write-Output "[ACTION] Uploading file to Google Drive using rclone..."
rclone copy "$($iterativeFile.FullName)" "AzaionGoogleDrive:$uploadFolder" --progress
if ($LASTEXITCODE -eq 0) {
Write-Output "[SUCCESS] ✅ Iterative installer uploaded successfully."
} else {
Write-Output "[ERROR] ❌ Upload failed with exit code $LASTEXITCODE."
}
} else {
Write-Output "[WARNING] ⚠️ No matching Iterative installer found in current directory."
}
Write-Output "=== Upload Complete: Iterative Installer ===`n"
-79
View File
@@ -1,79 +0,0 @@
// Jenkinsfile for Dependencies pipeline
pipeline {
agent { label 'Win10-BuildMachine' }
tools {
// Define any tools needed specifically for dependency installation
// e.g., NuGet, package managers, etc.
git 'Default' // Git is needed for checkout
dotnetsdk 'dotnet-sdk' // Assuming dotnet restore is part of dependencies
}
environment {
// Define any environment variables needed for dependency installation
// e.g., paths to package sources, etc.
REPO_ANNOTATOR_URL = 'git@github.com:azaion/annotator.git' // URL for Azaion repo
REPO_GPS_DENIED_URL = 'git@github.com:azaion/gps-denied.git' // URL for ImageMatcher repo
}
stages {
stage('Checkout') {
steps {
//Suite
checkout([
$class: 'GitSCM',
branches: [[name: '*/dev']],
userRemoteConfigs: [[
url: "${env.REPO_ANNOTATOR_URL}"
]],
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'suite']]
])
//GPS-Denied
checkout([
$class: 'GitSCM',
branches: [[name: '*/image-matcher']],
userRemoteConfigs: [[
url: "${env.REPO_GPS_DENIED_URL}"
]],
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'gps-denied']]
])
}
}
stage('Install Dependencies') {
steps {
echo 'Installing build dependencies...'
echo 'We do nothing here so far'
// Add steps here to install dependencies using PowerShell, command line, etc.
// Examples:
// powershell 'nuget restore suite/YourSolution.sln' // Assuming NuGet is in PATH or configured as a tool
// bat 'install_some_tool.bat'
// sh 'apt-get update && apt-get install -y some-package' // If using a mixed environment or WSL
// Example: Installing .NET dependencies using dotnet restore
// Assumes your solution file is within the 'suite' subdirectory and includes the gps-denied project
dir('suite') { // Change directory to the suite subdirectory where the solution file is
bat 'dotnet restore' // Assuming dotnet is in PATH or configured as a tool
}
// If your solution file is at the workspace root, you would use:
// bat 'dotnet restore'
}
}
}
post {
success {
echo 'Dependencies installed successfully. Triggering ImageMatcher Build pipeline...'
// Trigger the ImageMatcher Build pipeline job upon success
build job: 'ImageMatcher',
wait: false // Set to true if you want Dependencies to wait for ImageMatcher to finish
// No parameters are passed by default, add if needed
}
failure {
echo 'Dependencies installation failed. ImageMatcher Build pipeline will NOT be triggered.'
// Optional: Add other actions for failure, like sending notifications
}
// Optional: Add always, unstable, etc. blocks if needed
}
}
-167
View File
@@ -1,167 +0,0 @@
pipeline {
agent { label 'Win10-BuildMachine' }
tools {
git 'Default'
}
parameters {
string(name: 'buildPath', defaultValue: 'C:/Jenkins/workspace/Azaion/suite', description: 'Path to folder containing zip builds.')
}
environment {
GOOGLE_DRIVE_FOLDER = 'AzaionSuiteBuilds' // Hardcoded folder on Google Drive
RCLONE_CONFIG = 'C:/Program Files/rclone/rclone.conf'
}
stages {
stage('Initialize Workspace') {
steps {
echo 'Initializing workspace on Windows agent...'
powershell '''
$uploadDir = "temp_upload"
if (-Not (Test-Path $uploadDir)) {
New-Item -ItemType Directory -Path $uploadDir | Out-Null
}
'''
}
}
stage('Find Latest Zip') {
steps {
script {
echo "Using build path: ${params.buildPath}" // Debug output for build path
echo "Finding latest zip file in: ${params.buildPath}"
def latestZipFilename = ''
dir("${params.buildPath}") {
def output = powershell(returnStdout: true, script: '''
$pattern = "AzaionSuite*.zip"
$zipFiles = Get-ChildItem -Filter $pattern | Sort-Object Name -Descending
if ($zipFiles.Count -gt 0) {
$latestZip = $zipFiles[0].Name
Write-Output "::SET-ENV::LATEST_ZIP_FILENAME=$latestZip"
} else {
Write-Output "::SET-ENV::LATEST_ZIP_FILENAME="
}
''').trim()
// Debug output to verify the response from the powershell script
echo "PowerShell output: ${output}"
def match = output =~ /::SET-ENV::LATEST_ZIP_FILENAME=(.+)/
if (!match || !match[0][1]?.trim()) {
echo "⚠️ No ZIP files matching the pattern were found. Skipping upload and cleanup stages."
} else {
latestZipFilename = match[0][1]
echo "✅ Latest zip file selected: ${latestZipFilename}"
}
}
// Pass the filename to the next stages directly
env.LATEST_ZIP_FILENAME = latestZipFilename
echo "LATEST_ZIP_FILENAME after processing: ${env.LATEST_ZIP_FILENAME}"
}
}
}
stage('Upload If Not Exists & Always Remove Local') {
when {
expression {
echo "LATEST_ZIP_FILENAME is: '${env.LATEST_ZIP_FILENAME}'" // Debug output
return env.LATEST_ZIP_FILENAME?.trim()
}
}
steps {
echo "Checking Google Drive for existing ZIP and uploading if needed..."
powershell """
\$fileName = "${env.LATEST_ZIP_FILENAME}"
\$folder = "${GOOGLE_DRIVE_FOLDER}"
\$rcloneRemote = "AzaionGoogleDrive:\$folder"
\$localFilePath = "${params.buildPath}/\$fileName"
Write-Output "Checking for existing files in: \$rcloneRemote"
\$existingFiles = rclone lsf --files-only \$rcloneRemote
Write-Output "Existing files:"
Write-Output \$existingFiles
if (\$existingFiles -match "^\$fileName\$") {
Write-Output "File '\$fileName' already exists on Google Drive. Skipping upload."
} else {
Write-Output "Uploading '\$fileName' to Google Drive..."
rclone copy "\$localFilePath" \$rcloneRemote --progress --drive-chunk-size 64M
Write-Output "Upload complete."
}
if (Test-Path \$localFilePath) {
Remove-Item -Force \$localFilePath
Write-Output "Local file deleted: \$localFilePath"
} else {
Write-Output "Local file already deleted or not found."
}
"""
}
}
stage('Cleanup Older Files on Google Drive') {
when {
expression {
echo "LATEST_ZIP_FILENAME is: '${env.LATEST_ZIP_FILENAME}'" // Debug output
return env.LATEST_ZIP_FILENAME?.trim()
}
}
steps {
echo "Cleaning up older files on Google Drive..."
powershell """
Write-Output "Listing all files in the folder ${GOOGLE_DRIVE_FOLDER} on Google Drive..."
\$files = rclone lsf --files-only AzaionGoogleDrive:${GOOGLE_DRIVE_FOLDER}
Write-Output "Files found on Google Drive:"
Write-Output \$files
\$filesArray = \$files -split "`n" | Where-Object { \$_ -ne "" }
if (\$filesArray.Count -gt 3) {
\$filesSorted = \$filesArray | Sort-Object -Descending
\$filesToDelete = \$filesSorted | Select-Object -Skip 3
Write-Output "Files to delete (older than 3 latest):"
Write-Output \$filesToDelete
if (\$filesToDelete.Count -gt 0) {
\$tempFile = [System.IO.Path]::GetTempFileName()
\$filesToDelete | Set-Content -Path \$tempFile -Encoding utf8
Write-Output "Contents of temporary delete list file (\$tempFile):"
Get-Content \$tempFile
foreach (\$file in \$filesToDelete) {
Write-Output "Deleting \$file..."
rclone deletefile AzaionGoogleDrive:${GOOGLE_DRIVE_FOLDER}/\$file
}
Remove-Item -Path \$tempFile
} else {
Write-Output "No files to delete."
}
} else {
Write-Output "No files found on Google Drive to clean up."
}
"""
}
}
}
post {
always {
echo 'Executing post-build cleanup...'
powershell '''
$uploadDir = "temp_upload"
if (Test-Path $uploadDir) {
Remove-Item -Recurse -Force $uploadDir
}
'''
}
failure {
echo 'Pipeline failed. Check logs for details.'
}
}
}
-68
View File
@@ -1,68 +0,0 @@
// Jenkinsfile for ImageMatcher Build pipeline
pipeline {
// Ensure this runs on your Windows agent
agent {
label 'Win10-BuildMachine' // Specify the agent label type and value directly
// Removed: workspace 'C:/Jenkins/workspace/BuildDependencies'
// We will use a dir() step within the stage's steps block instead.
}
tools {
// Define any tools needed specifically for building ImageMatcher
git 'Default' // Git is NOT needed for checkout in this pipeline
// dotnetsdk 'dotnet-sdk' // If ImageMatcher is a .NET project
}
environment {
// Define environment variables specific to ImageMatcher
// REPO_GPS_DENIED_URL = 'git@github.com:azaion/gps-denied.git' // Not needed for checkout
// Add any other environment variables needed for the build (e.g., build configuration)
CONFIGURATION = 'Release' // Example build configuration
// Define the path to the shared workspace
SHARED_WORKSPACE = 'C:/Jenkins/workspace/Azaion' // Define shared workspace path
}
stages {
stage('Build ImageMatcher') {
steps {
echo "Building ImageMatcher in shared workspace: ${env.SHARED_WORKSPACE}"
// Use a dir() step to ensure the build command runs in the shared workspace
dir(env.SHARED_WORKSPACE) {
// The code is expected to be in the 'gps-denied' subdirectory relative to the shared workspace
echo "Running ImageMatcher dependency installation script..."
// Run the install_dependencies_win script located in the gps-denied subdirectory
// Use bat as it's a Windows script
bat 'gps-denied\\install_dependencies_win.cmd' // **Added step to run dependency script**
echo "ImageMatcher dependency installation script finished."
echo "Running ImageMatcher build command..."
dir('gps-denied\\image-matcher') { // Change directory to the ImageMatcher build location relative to SHARED_WORKSPACE
bat 'build.cmd' // Replace with the actual build command
}
echo "ImageMatcher build command finished."
}
}
}
}
post {
success {
echo 'ImageMatcher built successfully. Triggering Azaion Build pipeline...'
// Trigger the Azaion Build pipeline job upon success
// 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) ]
// If Azaion Build needs ImageMatcher artifacts, it will use copyArtifacts.
}
failure {
echo 'ImageMatcher build failed. Azaion Build pipeline will NOT be triggered.'
// Optional: Add other actions for failure, like sending notifications
}
// Optional: Add always, unstable, etc. blocks if needed
}
}
-238
View File
@@ -1,238 +0,0 @@
// 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
// 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), 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 {
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
// 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' // Assuming this is the workspace path on the agent
def version = '1.0.0' // Default version
def filesToUpload = []
// Define the date formatter (for folder name)
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 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 for Nexus deployment. 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
}
}
-133
View File
@@ -1,133 +0,0 @@
pipeline {
agent { label 'Win10-BuildMachine' }
parameters {
string(name: 'buildPath', defaultValue: 'C:/Jenkins/workspace/Azaion/suite', description: 'Build directory to zip from')
}
tools {
git 'Default'
}
environment {
SEVEN_ZIP_PATH = "C:/Program Files/7-Zip"
PATH = "${SEVEN_ZIP_PATH};${env.PATH}"
GOOGLE_DRIVE_UPLOAD_JOB_NAME = 'GDrive Upload'
}
stages {
stage('Detect or Create Zip') {
steps {
script {
echo "Starting 'Detect or Create Zip' stage."
echo "Using build path: ${params.buildPath}"
dir("${params.buildPath}") {
powershell '''
$ErrorActionPreference = "Stop"
$sevenZipExe = "$env:SEVEN_ZIP_PATH\\7z.exe"
$exePattern = "AzaionSuite*.exe"
$binPattern = "AzaionSuite*.bin"
$zipPattern = "AzaionSuite*.zip"
if (-not (Test-Path $sevenZipExe)) {
Write-Error "7-Zip not found at $sevenZipExe"
exit 1
}
$existingZips = Get-ChildItem -Path . -Filter $zipPattern | Sort-Object LastWriteTime -Descending
$zipFilename = ""
if ($existingZips.Count -gt 0) {
$zipFilename = $existingZips[0].Name
Write-Host "Using existing zip file: $zipFilename"
$wasCreated = $false
} else {
$exeFile = Get-ChildItem -Recurse -Filter $exePattern | Select-Object -First 1
if (-not $exeFile) {
Write-Error "No EXE file found to create zip"
exit 1
}
$zipBaseFilename = $exeFile.BaseName
$timestamp = (Get-Date -Format "yyyyMMdd-HHmmss")
$zipFilename = "$zipBaseFilename-$timestamp.zip"
$filesToZip = Get-ChildItem -Recurse -Include $exePattern, $binPattern | Select-Object -ExpandProperty FullName
if ($filesToZip.Count -eq 0) {
Write-Error "No files found to zip."
exit 1
}
$args = @("a", "-tzip", "$zipFilename") + ($filesToZip | ForEach-Object { "`"$_`"" })
$process = Start-Process -FilePath $sevenZipExe -ArgumentList $args -Wait -NoNewWindow -PassThru
if ($process.ExitCode -ne 0) {
Write-Error "7-Zip failed with code $($process.ExitCode)"
exit $process.ExitCode
}
$wasCreated = $true
Write-Host "Created new zip file: $zipFilename"
}
Set-Content -Path "zipfilename.txt" -Value $zipFilename -Encoding ASCII
Set-Content -Path "zip_was_created.txt" -Value $wasCreated -Encoding ASCII
'''
def zipFilename = readFile('zipfilename.txt').trim()
def zipCreated = readFile('zip_was_created.txt').trim().toBoolean()
echo "Zip filename: ${zipFilename}"
echo "Was zip created this run? ${zipCreated}"
writeFile file: 'created_zip.txt', text: zipFilename
writeFile file: 'zip_was_created.txt', text: zipCreated.toString()
}
}
}
}
stage('Archive Zip File (if new)') {
when {
expression {
def zipCreated = readFile("${params.buildPath}/zip_was_created.txt").trim().toBoolean()
return zipCreated
}
}
steps {
script {
echo "Archiving newly created zip file..."
dir("${params.buildPath}") {
def zipFilename = readFile('created_zip.txt').trim()
if (!fileExists(zipFilename)) {
error "Zip file '${zipFilename}' not found!"
}
archiveArtifacts artifacts: "${zipFilename}", fingerprint: true
}
}
}
}
stage('Trigger Google Drive Upload') {
steps {
script {
echo "Triggering Google Drive Upload pipeline: ${env.GOOGLE_DRIVE_UPLOAD_JOB_NAME}"
build job: env.GOOGLE_DRIVE_UPLOAD_JOB_NAME, parameters: [
string(name: 'buildPath', value: params.buildPath)
]
}
}
}
}
post {
success {
script {
def zipFilename = readFile("${params.buildPath}/created_zip.txt").trim()
echo "Pipeline completed successfully. Final zip: ${zipFilename}"
}
}
failure {
echo "Pipeline failed."
}
}
}
-105
View File
@@ -1,105 +0,0 @@
@echo off
setlocal enabledelayedexpansion
:: Move one level up
cd /d ..
echo [INFO] Changed working directory to: %CD%
:: Get timestamp
for /f %%a in ('powershell -NoProfile -Command "Get-Date -Format yyyyMMdd-HHmmss"') do set "timestamp=%%a"
set "fullZipCreated=0"
set "iterZipCreated=0"
:: ===== FULL BUILD =====
set "fullExe="
for %%F in (AzaionSuite.Full.*.exe) do (
set "fullExe=%%F"
goto :FullExeFound
)
echo [WARNING] No Full build EXE found [AzaionSuite.Full.*.exe]
goto :AfterFullBuild
:FullExeFound
echo [INFO] Found Full build EXE: [%fullExe%]
set "baseFull=%fullExe:.exe=%"
:: Collect BIN files for Full build
set "fullBinList="
for %%B in (%baseFull%-*.bin) do (
echo [INFO] Found BIN file: [%%B]
if defined fullBinList (
set "fullBinList=!fullBinList!,\"%%B\""
) else (
set "fullBinList=\"%%B\""
)
)
echo [INFO] BIN files list: %fullBinList%
:: Compose PowerShell command for Full
if "%fullBinList%"=="" (
set "fullPsCmd=Compress-Archive -Force -Path \"%fullExe%\" -DestinationPath \"%baseFull%-%timestamp%.zip\""
) else (
set "fullPsCmd=Compress-Archive -Force -Path \"%fullExe%\",%fullBinList% -DestinationPath \"%baseFull%-%timestamp%.zip\""
)
echo [INFO] Creating ZIP: [%baseFull%-%timestamp%.zip]
echo [INFO] Using PowerShell command to compress:
echo powershell -Command "%fullPsCmd%"
powershell -Command "%fullPsCmd%"
if errorlevel 1 (
echo [ERROR] Failed to create Full archive: [%baseFull%-%timestamp%.zip]
) else (
echo [SUCCESS] Full archive created: [%baseFull%-%timestamp%.zip]
set "fullZipCreated=1"
)
:AfterFullBuild
:: ===== ITERATIVE BUILD =====
set "iterExe="
for %%I in (AzaionSuite.Iterative.*.exe) do (
set "iterExe=%%I"
goto :IterExeFound
)
echo [WARNING] No Iterative build EXE found [AzaionSuite.Iterative.*.exe]
goto :AfterIterBuild
:IterExeFound
echo [INFO] Found Iterative build EXE: [%iterExe%]
set "baseIter=%iterExe:.exe=%"
:: Iterative pack (exe only)
set "iterPsCmd=Compress-Archive -Force -Path \"%iterExe%\" -DestinationPath \"%baseIter%-%timestamp%.zip\""
echo [INFO] Creating ZIP: [%baseIter%-%timestamp%.zip]
echo [INFO] Using PowerShell command to compress:
echo powershell -Command "%iterPsCmd%"
powershell -Command "%iterPsCmd%"
if errorlevel 1 (
echo [ERROR] Failed to create Iterative archive: [%baseIter%-%timestamp%.zip]
) else (
echo [SUCCESS] Iterative archive created: [%baseIter%-%timestamp%.zip]
set "iterZipCreated=1"
)
:AfterIterBuild
echo.
if "%fullZipCreated%"=="1" (
if "%iterZipCreated%"=="1" (
echo [DONE] Both Full and Iterative packaging complete.
) else (
echo [DONE] Full packaging complete. No Iterative package created.
)
) else (
if "%iterZipCreated%"=="1" (
echo [DONE] Iterative packaging complete. No Full package created.
) else (
echo [INFO] No packages were created.
)
)
+69
View File
@@ -0,0 +1,69 @@
# zip_full.ps1
$host.UI.RawUI.WindowTitle = "Full Installer Zipper"
Write-Host "`n===== [AZAION SUITE FULL PACKAGER] =====" -ForegroundColor Cyan
function Show-ProgressBar {
param (
[string]$Activity,
[int]$Steps = 20,
[int]$Delay = 30
)
for ($i = 1; $i -le $Steps; $i++) {
$percent = [math]::Round(($i / $Steps) * 100)
$bar = ("#" * $i).PadRight($Steps)
Write-Host -NoNewline "`r[PROGRESS] $Activity [$bar] $percent% "
Start-Sleep -Milliseconds $Delay
}
Write-Host ""
}
Write-Host "[INFO] Preparing to package Full installer..." -ForegroundColor Yellow
Set-Location -Path (Split-Path -Parent $MyInvocation.MyCommand.Path)
Set-Location ..
$currentDir = Get-Location
Write-Host "[INFO] Working directory: $currentDir" -ForegroundColor Gray
# Locate Full EXE
$fullExe = Get-ChildItem -Filter "AzaionSuite.Full.*.exe" | Select-Object -First 1
if (-not $fullExe) {
Write-Host "[ERROR] ❌ No Full build EXE found (AzaionSuite.Full.*.exe)" -ForegroundColor Red
exit 1
}
Write-Host "[OK] ✅ Found Full EXE: $($fullExe.Name)" -ForegroundColor Green
# Match BIN files
$baseName = [System.IO.Path]::GetFileNameWithoutExtension($fullExe.Name)
$binFiles = Get-ChildItem -Filter "$baseName-*.bin"
if ($binFiles.Count -gt 0) {
Write-Host "[INFO] Matching BIN files found:" -ForegroundColor Cyan
$binFiles | ForEach-Object { Write-Host " - $_" -ForegroundColor DarkCyan }
} else {
Write-Host "[INFO] No BIN files found. Creating ZIP with only EXE." -ForegroundColor Yellow
}
# Compose final ZIP path
$zipName = "$baseName.zip"
$zipPath = Join-Path -Path $currentDir -ChildPath $zipName
# Collect files to zip
$toZip = @($fullExe.FullName)
$toZip += $binFiles.FullName
Write-Host "[INFO] Creating ZIP file: $zipName" -ForegroundColor Yellow
Show-ProgressBar -Activity "Compressing files..." -Steps 25 -Delay 25
try {
Compress-Archive -Force -Path $toZip -DestinationPath $zipPath -Verbose
Write-Host "[SUCCESS] 🎉 ZIP archive created successfully: $zipName" -ForegroundColor Green
} catch {
Write-Host "[ERROR] ❌ Failed to create ZIP archive: $_" -ForegroundColor Red
exit 1
}
Write-Host "`n[FINISHED] ✅ Full installer packaging complete." -ForegroundColor Cyan