zip update

This commit is contained in:
dzaitsev
2025-05-04 13:54:32 +03:00
parent d5057dd86c
commit fcda29fd49
+12 -4
View File
@@ -54,7 +54,7 @@ pipeline {
// Use a powershell step to check for existing zip, or create a new one, then output the filename
// Capture the output of the powershell script
// Capture the output of the powershell script, redirecting stderr to stdout
def zipFilenameOutput = powershell returnStdout: true, script: '''
$ErrorActionPreference = "Stop" # Stop the script on any error
@@ -166,12 +166,19 @@ pipeline {
Write-Output $zipFilename
exit 0
''' // End powershell script
''' 2>&1 // End powershell script and redirect stderr to stdout
// 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}"
// Use readLines() to handle multi-line output and get the last line
def outputLines = zipFilenameOutput.readLines()
if (!outputLines.isEmpty()) {
env.CREATED_ZIP_FILENAME = outputLines.last().trim()
echo "Set CREATED_ZIP_FILENAME environment variable to: ${env.CREATED_ZIP_FILENAME}"
} else {
error "PowerShell script did not produce any output to capture the zip filename."
}
} // End dir block
}
@@ -194,6 +201,7 @@ pipeline {
archiveArtifacts artifacts: "${createdZipFilename}", fingerprint: true
echo "Archive step completed."
} else {
// This error should now be less likely with improved output capturing
error "CREATED_ZIP_FILENAME environment variable was not set or was empty. Cannot archive."
}
} // End dir block