gdrive update

This commit is contained in:
dzaitsev
2025-05-04 15:00:58 +03:00
parent 78caeac943
commit f42646bc72
+12 -3
View File
@@ -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) {