mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 21:46:30 +00:00
zip update
This commit is contained in:
+17
-10
@@ -30,7 +30,7 @@ pipeline {
|
||||
|
||||
// Define the name of the created zip file as an environment variable
|
||||
// This makes it easier to reference in later stages
|
||||
CREATED_ZIP_FILENAME = '' // This will be set dynamically
|
||||
CREATED_ZIP_FILENAME = '' // This will be set dynamically by capturing PowerShell output
|
||||
}
|
||||
|
||||
stages {
|
||||
@@ -49,12 +49,13 @@ pipeline {
|
||||
// These are now defined as literals within the PowerShell script string
|
||||
// def exePattern = 'AzaionSuite*.exe'
|
||||
// def binPattern = 'AzaionSuite*.bin'
|
||||
// Define defaultVersion here, used if version extraction fails
|
||||
// Define defaultVersion here, used if no exe is found
|
||||
// def defaultVersion = '1.0.0'
|
||||
|
||||
|
||||
// Use a powershell step to perform file finding, filename extraction, timestamp generation, and zipping
|
||||
powershell '''
|
||||
// Capture the output of the powershell script
|
||||
def zipFilenameOutput = powershell returnStdout: true, script: '''
|
||||
$ErrorActionPreference = "Stop" # Stop the script on any error
|
||||
|
||||
$sevenZipExe = "$env:SEVEN_ZIP_PATH\\7z.exe"
|
||||
@@ -89,7 +90,7 @@ pipeline {
|
||||
|
||||
# --- Zipping Logic ---
|
||||
|
||||
# Get current date and time in YYYYMMDD-HHmmss format
|
||||
# Get current date and time inYYYYMMDD-HHmmss format
|
||||
$timestamp = (Get-Date -Format "yyyyMMdd-HHmmss")
|
||||
|
||||
# Construct the zip filename using the base filename and timestamp
|
||||
@@ -124,13 +125,19 @@ pipeline {
|
||||
|
||||
Write-Host "Zip archive created successfully by 7-Zip: $zipFilename"
|
||||
|
||||
# Output the zip filename and set it as an environment variable for Jenkins
|
||||
# This uses the Jenkins 'set context' feature
|
||||
Write-Host "::SET-ZIP-FILENAME::$zipFilename"
|
||||
Write-Host "::SET-ENV::CREATED_ZIP_FILENAME=$zipFilename"
|
||||
# Output the zip filename to standard output for the Groovy script to capture
|
||||
# Write-Host "::SET-ZIP-FILENAME::$zipFilename" # Removed, using Write-Output instead
|
||||
# Write-Host "::SET-ENV::CREATED_ZIP_FILENAME=$zipFilename" # Removed, using Write-Output instead
|
||||
Write-Output $zipFilename
|
||||
|
||||
exit 0
|
||||
''' // End powershell script
|
||||
|
||||
// Capture the output and set the environment variable
|
||||
// The PowerShell script outputs the zip filename as the last line
|
||||
env.CREATED_ZIP_FILENAME = zipFilenameOutput.trim()
|
||||
echo "Set CREATED_ZIP_FILENAME environment variable to: ${env.CREATED_ZIP_FILENAME}"
|
||||
|
||||
} // End dir block
|
||||
}
|
||||
}
|
||||
@@ -145,14 +152,14 @@ pipeline {
|
||||
// The zip filename was set as an environment variable in the previous stage
|
||||
def createdZipFilename = env.CREATED_ZIP_FILENAME
|
||||
|
||||
if (createdZipFilename) {
|
||||
if (createdZipFilename && !createdZipFilename.trim().isEmpty()) {
|
||||
echo "Identified created zip file for archiving: ${createdZipFilename}"
|
||||
// Archive the created zip file using Jenkins built-in step
|
||||
// The zip file is created in the MAIN_BUILD_ARTIFACTS_DIR by the Batch script
|
||||
archiveArtifacts artifacts: "${createdZipFilename}", fingerprint: true
|
||||
echo "Archive step completed."
|
||||
} else {
|
||||
error "CREATED_ZIP_FILENAME environment variable was not set. Cannot archive."
|
||||
error "CREATED_ZIP_FILENAME environment variable was not set or was empty. Cannot archive."
|
||||
}
|
||||
} // End dir block
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user