mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 08:46:31 +00:00
pipelines zip and gdrive upload
updated
This commit is contained in:
@@ -92,19 +92,23 @@ pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
stage('Cleanup Older Files on Google Drive') {
|
||||
stage('Cleanup Older Files on Google Drive') {
|
||||
when {
|
||||
expression { return env.LATEST_ZIP_FILENAME?.trim() }
|
||||
}
|
||||
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
|
||||
@@ -133,7 +137,7 @@ pipeline {
|
||||
}
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
|
||||
Reference in New Issue
Block a user