zip update

This commit is contained in:
dzaitsev
2025-05-04 13:40:28 +03:00
parent 1277ebffc6
commit 30d97c6244
+11 -25
View File
@@ -53,12 +53,12 @@ pipeline {
// def defaultVersion = '1.0.0' // def defaultVersion = '1.0.0'
// Use a powershell step to perform file finding, version extraction, timestamp generation, and zipping // Use a powershell step to perform file finding, filename extraction, timestamp generation, and zipping
powershell ''' powershell '''
$ErrorActionPreference = "Stop" # Stop the script on any error $ErrorActionPreference = "Stop" # Stop the script on any error
$sevenZipExe = "$env:SEVEN_ZIP_PATH\\7z.exe" $sevenZipExe = "$env:SEVEN_ZIP_PATH\\7z.exe"
$defaultVersion = "1.0.0" # Default version if extraction fails $defaultVersion = "1.0.0" # Default version if no exe is found
$exePattern = "AzaionSuite*.exe" $exePattern = "AzaionSuite*.exe"
$binPattern = "AzaionSuite*.bin" $binPattern = "AzaionSuite*.bin"
@@ -74,31 +74,17 @@ pipeline {
Write-Host "Found $($foundFiles.Count) file(s) to archive." Write-Host "Found $($foundFiles.Count) file(s) to archive."
# --- Version Extraction (from .exe if present) --- # --- Determine Base Filename for Zip (from .exe if present) ---
$version = $defaultVersion $zipBaseFilename = "AzaionSuite.$defaultVersion" # Default base filename
$exeFile = Get-ChildItem -Recurse -Path . -Filter $exePattern | Select-Object -First 1 $exeFile = Get-ChildItem -Recurse -Path . -Filter $exePattern | Select-Object -First 1
if ($exeFile) { if ($exeFile) {
Write-Host "Attempting to extract version from '$($exeFile.FullName)'..." Write-Host "Executable file found: '$($exeFile.FullName)'"
try { # Extract filename without extension
# Get file version info $zipBaseFilename = $exeFile.BaseName
$versionInfo = Get-ItemProperty -Path $exeFile.FullName -Name VersionInfo Write-Host "Using executable base filename for archive name: '$zipBaseFilename'"
# Prefer ProductVersion, fallback to FileVersion
if ($versionInfo.ProductVersion) {
$version = $versionInfo.ProductVersion
Write-Host "Extracted ProductVersion: $version"
} elseif ($versionInfo.FileVersion) {
$version = $versionInfo.FileVersion
Write-Host "Extracted FileVersion: $version"
} else { } else {
Write-Warning "Could not extract ProductVersion or FileVersion from '$($exeFile.Name)'. Using default: $version" Write-Warning "No executable found matching $exePattern. Using default base filename: '$zipBaseFilename'"
}
} catch {
Write-Warning "Error extracting version from '$($exeFile.Name)': $_`nUsing default: $version"
}
} else {
Write-Warning "No executable found matching $exePattern to extract version. Using default: $version"
} }
# --- Zipping Logic --- # --- Zipping Logic ---
@@ -106,8 +92,8 @@ pipeline {
# Get current date and time in YYYYMMDD-HHmmss format # Get current date and time in YYYYMMDD-HHmmss format
$timestamp = (Get-Date -Format "yyyyMMdd-HHmmss") $timestamp = (Get-Date -Format "yyyyMMdd-HHmmss")
# Construct the zip filename using extracted version and timestamp # Construct the zip filename using the base filename and timestamp
$zipFilename = "AzaionSuite.$version-$timestamp.zip" $zipFilename = "$zipBaseFilename-$timestamp.zip"
Write-Host "Creating zip archive: $zipFilename using 7-Zip." Write-Host "Creating zip archive: $zipFilename using 7-Zip."