gdrive update

This commit is contained in:
dzaitsev
2025-05-04 14:58:19 +03:00
parent 5d0e49b6fd
commit efde78ad93
+21
View File
@@ -74,6 +74,27 @@ pipeline {
""" """
} }
} }
stage('Cleanup Older Files on Google Drive') {
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
# Keep only the 3 latest files
\$filesToDelete = \$files | Select-Object -Skip 3
# If there are files to delete, remove them
if (\$filesToDelete.Count -gt 0) {
Write-Output "Deleting files: \$filesToDelete"
rclone delete AzaionGoogleDrive:${params.GOOGLE_DRIVE_FOLDER} --files-from <(echo \$filesToDelete) --drive-chunk-size 64M
} else {
Write-Output "No files to delete."
}
"""
}
}
} }
post { post {