mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 11:16:30 +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 {
|
when {
|
||||||
expression { return env.LATEST_ZIP_FILENAME?.trim() }
|
expression { return env.LATEST_ZIP_FILENAME?.trim() }
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
echo "Cleaning up older files on Google Drive..."
|
echo "Cleaning up older files on Google Drive..."
|
||||||
powershell """
|
powershell """
|
||||||
Write-Output "Listing all files in the folder ${env.GOOGLE_DRIVE_FOLDER} on Google Drive..."
|
Write-Output "Listing all files in the folder ${params.GOOGLE_DRIVE_FOLDER} on Google Drive..."
|
||||||
\$files = rclone lsf --files-only AzaionGoogleDrive:${env.GOOGLE_DRIVE_FOLDER}
|
\$files = rclone lsf --files-only AzaionGoogleDrive:${params.GOOGLE_DRIVE_FOLDER}
|
||||||
Write-Output "Files found on Google Drive:"
|
Write-Output "Files found on Google Drive:"
|
||||||
Write-Output \$files
|
Write-Output \$files
|
||||||
|
|
||||||
\$filesArray = \$files -split "`n" | Where-Object { \$_ -ne "" }
|
\$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) {
|
if (\$filesArray.Count -gt 3) {
|
||||||
\$filesSorted = \$filesArray | Sort-Object -Descending
|
\$filesSorted = \$filesArray | Sort-Object -Descending
|
||||||
\$filesToDelete = \$filesSorted | Select-Object -Skip 3
|
\$filesToDelete = \$filesSorted | Select-Object -Skip 3
|
||||||
@@ -121,7 +125,7 @@ pipeline {
|
|||||||
|
|
||||||
foreach (\$file in \$filesToDelete) {
|
foreach (\$file in \$filesToDelete) {
|
||||||
Write-Output "Deleting \$file..."
|
Write-Output "Deleting \$file..."
|
||||||
rclone deletefile AzaionGoogleDrive:${env.GOOGLE_DRIVE_FOLDER}/\$file
|
rclone deletefile AzaionGoogleDrive:${params.GOOGLE_DRIVE_FOLDER}/\$file
|
||||||
}
|
}
|
||||||
|
|
||||||
Remove-Item -Path \$tempFile
|
Remove-Item -Path \$tempFile
|
||||||
@@ -133,7 +137,7 @@ pipeline {
|
|||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
post {
|
post {
|
||||||
|
|||||||
Reference in New Issue
Block a user