From 7fff1d9af4c40553c99c8efb5b74ed44316a508a Mon Sep 17 00:00:00 2001 From: dzaitsev Date: Wed, 7 May 2025 19:14:09 +0300 Subject: [PATCH] pipelines zip and gdrive upload updated --- build/jenkins/GDriveUpload | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/build/jenkins/GDriveUpload b/build/jenkins/GDriveUpload index eb0b39d..b0958e3 100644 --- a/build/jenkins/GDriveUpload +++ b/build/jenkins/GDriveUpload @@ -22,9 +22,12 @@ pipeline { error "Zip file '${zipFilename}' not found in ${params.buildPath}" } - // Check if file already exists on Google Drive + // Replace 'your-working-remote' with your actual working rclone remote name + def remoteName = 'your-working-remote' + + // Check if file already exists def alreadyExists = powershell(script: """ - \$result = rclone ls remote:\"${env.GOOGLE_DRIVE_FOLDER}\" | Select-String "${zipFilename}" + \$result = rclone ls ${remoteName}:${env.GOOGLE_DRIVE_FOLDER} | Select-String "${zipFilename}" if (\$result) { return 1 } else { return 0 } """, returnStatus: true) == 1 @@ -33,18 +36,18 @@ pipeline { } else { echo "Uploading '${zipFilename}' to Google Drive folder '${env.GOOGLE_DRIVE_FOLDER}'..." powershell """ - rclone copy \"${zipFilename}\" remote:\"${env.GOOGLE_DRIVE_FOLDER}\" + rclone copy \"${zipFilename}\" ${remoteName}:${env.GOOGLE_DRIVE_FOLDER} """ } - // Retention logic – keep only latest 5 ZIPs + // Retention: keep only latest 5 echo "Cleaning up old ZIP files in Google Drive..." powershell """ - \$files = rclone lsf --files-only --format "t" --max-age 365d remote:\"${env.GOOGLE_DRIVE_FOLDER}\" | Sort-Object | Where-Object { \$_ -like "*.zip" } + \$files = rclone lsf --files-only ${remoteName}:${env.GOOGLE_DRIVE_FOLDER} | Sort-Object if (\$files.Count -gt 5) { \$filesToDelete = \$files | Select-Object -First (\$files.Count - 5) foreach (\$file in \$filesToDelete) { - rclone delete remote:\"${env.GOOGLE_DRIVE_FOLDER}/\$file\" + rclone delete ${remoteName}:${env.GOOGLE_DRIVE_FOLDER}/\$file } } """