mirror of
https://github.com/azaion/annotations.git
synced 2026-04-23 00:56:30 +00:00
zip update
This commit is contained in:
+12
-51
@@ -37,7 +37,8 @@ pipeline {
|
|||||||
echo "Operating in directory: ${pwd()}"
|
echo "Operating in directory: ${pwd()}"
|
||||||
|
|
||||||
// Use a powershell step with improved error handling and robustness
|
// Use a powershell step with improved error handling and robustness
|
||||||
def zipFilenameOutput = powershell returnStdout: true, script: '''
|
// First, create a PowerShell script to find the zip file using standard output
|
||||||
|
powershell '''
|
||||||
$ErrorActionPreference = "Stop" # Stop the script on any error
|
$ErrorActionPreference = "Stop" # Stop the script on any error
|
||||||
|
|
||||||
# Define key variables
|
# Define key variables
|
||||||
@@ -128,61 +129,21 @@ pipeline {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# This is the critical fix - we need to make sure this is the last thing output
|
# CRITICAL: Write the filename to a temporary file that we can read in Jenkins
|
||||||
# And ensure it's on its own line with no other text
|
$zipFilename | Out-File -FilePath "zipfilename.txt" -Encoding utf8 -NoNewline
|
||||||
Write-Host "ZIPFILENAME=$zipFilename"
|
Write-Host "Wrote zip filename to zipfilename.txt: $zipFilename"
|
||||||
exit 0
|
exit 0
|
||||||
'''
|
'''
|
||||||
|
|
||||||
// Debug: Print raw PowerShell output to see what we're getting
|
// Now read the file directly using readFile step
|
||||||
echo "Raw PowerShell output: ${zipFilenameOutput}"
|
def zipFilename = readFile(file: 'zipfilename.txt').trim()
|
||||||
|
echo "Read zip filename from file: ${zipFilename}"
|
||||||
|
|
||||||
// The output may have Windows line endings, split by any common line ending
|
// Set the environment variable
|
||||||
def outputLines = zipFilenameOutput.split('(?:\\r\\n|\\n|\\r)')
|
env.CREATED_ZIP_FILENAME = zipFilename
|
||||||
echo "Found ${outputLines.size()} lines in output"
|
echo "Set CREATED_ZIP_FILENAME to: ${env.CREATED_ZIP_FILENAME}"
|
||||||
|
|
||||||
def zipFilename = null
|
// Nothing needed here since we now write the filename to a file and read it directly
|
||||||
// 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 "Setting CREATED_ZIP_FILENAME to: ${env.CREATED_ZIP_FILENAME}"
|
|
||||||
} else {
|
|
||||||
// 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."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user