From 961c750f1f7f5360823a55b3e886dc6f3f6633e9 Mon Sep 17 00:00:00 2001 From: dzaitsev Date: Sun, 4 May 2025 18:52:08 +0300 Subject: [PATCH] latest fixes for Gdrive upload --- build/jenkins/GDriveUpload | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/build/jenkins/GDriveUpload b/build/jenkins/GDriveUpload index 2bd008b..50b1d23 100644 --- a/build/jenkins/GDriveUpload +++ b/build/jenkins/GDriveUpload @@ -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=" } - $latestZip = $zipFiles[0].Name - Write-Output "::SET-ENV::LATEST_ZIP_FILENAME=$latestZip" ''').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}" + env.LATEST_ZIP_FILENAME = zipFileName } - def zipFileName = match[0][1] - 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 """