latest fixes for Gdrive upload

This commit is contained in:
dzaitsev
2025-05-04 18:52:08 +03:00
parent 1acfab9b87
commit 961c750f1f
+17 -9
View File
@@ -32,29 +32,34 @@ pipeline {
echo "Finding latest zip file..."
dir("C:/Jenkins/workspace/AzaionSuite/suite") {
def output = powershell(returnStdout: true, script: '''
$pattern = "AzaionSuite.*-*-*.zip"
$pattern = "AzaionSuite*-*-*.zip"
$zipFiles = Get-ChildItem -Filter $pattern | Sort-Object Name -Descending
if ($zipFiles.Count -eq 0) {
Write-Error "No ZIP files matching pattern '$pattern' were found."
exit 1
}
if ($zipFiles.Count -gt 0) {
$latestZip = $zipFiles[0].Name
Write-Output "::SET-ENV::LATEST_ZIP_FILENAME=$latestZip"
} else {
Write-Output "::SET-ENV::LATEST_ZIP_FILENAME="
}
''').trim()
def match = output =~ /::SET-ENV::LATEST_ZIP_FILENAME=(.+)/
if (!match) {
error("Could not find the latest zip filename in the PowerShell output using marker.")
}
if (!match || !match[0][1]?.trim()) {
echo "⚠️ No ZIP files matching the pattern were found. Skipping upload and cleanup stages."
env.LATEST_ZIP_FILENAME = ''
} else {
def zipFileName = match[0][1]
echo "Latest zip file selected: ${zipFileName}"
echo "Latest zip file selected: ${zipFileName}"
env.LATEST_ZIP_FILENAME = zipFileName
}
}
}
}
}
stage('Upload If Not Exists & Always Remove Local') {
when {
expression { return env.LATEST_ZIP_FILENAME?.trim() }
}
steps {
echo "Checking Google Drive for existing ZIP and uploading if needed..."
powershell """
@@ -87,6 +92,9 @@ pipeline {
}
stage('Cleanup Older Files on Google Drive') {
when {
expression { return env.LATEST_ZIP_FILENAME?.trim() }
}
steps {
echo "Cleaning up older files on Google Drive..."
powershell """