diff --git a/build/jenkins/GDriveUpload b/build/jenkins/GDriveUpload index cbc5e48..1d2a1a3 100644 --- a/build/jenkins/GDriveUpload +++ b/build/jenkins/GDriveUpload @@ -79,11 +79,20 @@ pipeline { steps { echo "Cleaning up older files on Google Drive..." powershell """ - # Get the list of files in the Google Drive folder - \$files = rclone lsf --files-only --dirs-only --max-depth 1 AzaionGoogleDrive:${params.GOOGLE_DRIVE_FOLDER} --format "tp" | Sort-Object -Descending + # List all files in the Google Drive folder + Write-Output "Listing all files in the folder ${params.GOOGLE_DRIVE_FOLDER} on Google Drive..." + \$files = rclone lsf --files-only --dirs-only --max-depth 1 AzaionGoogleDrive:${params.GOOGLE_DRIVE_FOLDER} --format "tp" + Write-Output "Files found on Google Drive:" + Write-Output \$files + + # Sort the files by date in descending order + \$filesSorted = \$files | Sort-Object -Descending # Keep only the 3 latest files - \$filesToDelete = \$files | Select-Object -Skip 3 + \$filesToDelete = \$filesSorted | Select-Object -Skip 3 + + # Display the files to delete + Write-Output "Files to delete: \$filesToDelete" # If there are files to delete, remove them if (\$filesToDelete.Count -gt 0) {