mirror of
https://github.com/azaion/annotations.git
synced 2026-04-23 01:26:30 +00:00
gdrive update
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user