pipelines zip and gdrive upload

updated
This commit is contained in:
dzaitsev
2025-05-07 19:25:30 +03:00
parent 64c99d88ec
commit f7dd087fad
+7 -3
View File
@@ -99,12 +99,16 @@ pipeline {
steps {
echo "Cleaning up older files on Google Drive..."
powershell """
Write-Output "Listing all files in the folder ${env.GOOGLE_DRIVE_FOLDER} on Google Drive..."
\$files = rclone lsf --files-only AzaionGoogleDrive:${env.GOOGLE_DRIVE_FOLDER}
Write-Output "Listing all files in the folder ${params.GOOGLE_DRIVE_FOLDER} on Google Drive..."
\$files = rclone lsf --files-only AzaionGoogleDrive:${params.GOOGLE_DRIVE_FOLDER}
Write-Output "Files found on Google Drive:"
Write-Output \$files
\$filesArray = \$files -split "`n" | Where-Object { \$_ -ne "" }
# Exclude the latest zip file from deletion
\$latestFile = "${env.LATEST_ZIP_FILENAME}"
\$filesArray = \$filesArray | Where-Object { \$_ -ne \$latestFile }
if (\$filesArray.Count -gt 3) {
\$filesSorted = \$filesArray | Sort-Object -Descending
\$filesToDelete = \$filesSorted | Select-Object -Skip 3
@@ -121,7 +125,7 @@ pipeline {
foreach (\$file in \$filesToDelete) {
Write-Output "Deleting \$file..."
rclone deletefile AzaionGoogleDrive:${env.GOOGLE_DRIVE_FOLDER}/\$file
rclone deletefile AzaionGoogleDrive:${params.GOOGLE_DRIVE_FOLDER}/\$file
}
Remove-Item -Path \$tempFile