zip update

This commit is contained in:
dzaitsev
2025-05-04 14:14:28 +03:00
parent 604e3d132e
commit 98d99ec7be
+40 -7
View File
@@ -134,21 +134,54 @@ pipeline {
exit 0
'''
// Extract the zip filename from the PowerShell output by looking for "ZIPFILENAME=" prefix
def outputLines = zipFilenameOutput.split('\n')
// Debug: Print raw PowerShell output to see what we're getting
echo "Raw PowerShell output: ${zipFilenameOutput}"
// The output may have Windows line endings, split by any common line ending
def outputLines = zipFilenameOutput.split('(?:\\r\\n|\\n|\\r)')
echo "Found ${outputLines.size()} lines in output"
def zipFilename = null
for (line in outputLines) {
if (line.trim().startsWith("ZIPFILENAME=")) {
zipFilename = line.trim() - "ZIPFILENAME="
// Debug: Print each line of output
for (int i = 0; i < outputLines.size(); i++) {
echo "Line ${i}: ${outputLines[i]}"
if (outputLines[i].trim().contains("ZIPFILENAME=")) {
zipFilename = outputLines[i].trim().substring(outputLines[i].trim().indexOf("ZIPFILENAME=") + 11)
echo "Found zip filename in line ${i}: ${zipFilename}"
break
}
}
if (zipFilename) {
env.CREATED_ZIP_FILENAME = zipFilename.trim()
echo "Found zip filename: ${env.CREATED_ZIP_FILENAME}"
echo "Setting CREATED_ZIP_FILENAME to: ${env.CREATED_ZIP_FILENAME}"
} else {
error "Failed to extract zip filename from PowerShell output. Check PowerShell script."
// If we can't find the ZIPFILENAME marker, try a fallback approach
// Look for the line containing "Using newest existing zip file:" or "Zip archive created successfully:"
for (int i = 0; i < outputLines.size(); i++) {
def line = outputLines[i].trim()
if (line.contains("Using newest existing zip file: '") && line.contains(".zip'")) {
def start = line.indexOf("'") + 1
def end = line.lastIndexOf("'")
if (start > 0 && end > start) {
zipFilename = line.substring(start, end)
echo "Extracted zip filename from 'Using newest' line: ${zipFilename}"
break
}
} else if (line.contains("Zip archive created successfully: ") && line.contains(".zip")) {
def start = line.indexOf("Zip archive created successfully: ") + 30
zipFilename = line.substring(start).trim()
echo "Extracted zip filename from 'created successfully' line: ${zipFilename}"
break
}
}
if (zipFilename) {
env.CREATED_ZIP_FILENAME = zipFilename.trim()
echo "Setting CREATED_ZIP_FILENAME using fallback to: ${env.CREATED_ZIP_FILENAME}"
} else {
error "Failed to extract zip filename from PowerShell output after multiple attempts. Check PowerShell script."
}
}
}
}