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:
@@ -22,9 +22,12 @@ pipeline {
|
|||||||
error "Zip file '${zipFilename}' not found in ${params.buildPath}"
|
error "Zip file '${zipFilename}' not found in ${params.buildPath}"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if file already exists on Google Drive
|
// Replace 'your-working-remote' with your actual working rclone remote name
|
||||||
|
def remoteName = 'your-working-remote'
|
||||||
|
|
||||||
|
// Check if file already exists
|
||||||
def alreadyExists = powershell(script: """
|
def alreadyExists = powershell(script: """
|
||||||
\$result = rclone ls remote:\"${env.GOOGLE_DRIVE_FOLDER}\" | Select-String "${zipFilename}"
|
\$result = rclone ls ${remoteName}:${env.GOOGLE_DRIVE_FOLDER} | Select-String "${zipFilename}"
|
||||||
if (\$result) { return 1 } else { return 0 }
|
if (\$result) { return 1 } else { return 0 }
|
||||||
""", returnStatus: true) == 1
|
""", returnStatus: true) == 1
|
||||||
|
|
||||||
@@ -33,18 +36,18 @@ pipeline {
|
|||||||
} else {
|
} else {
|
||||||
echo "Uploading '${zipFilename}' to Google Drive folder '${env.GOOGLE_DRIVE_FOLDER}'..."
|
echo "Uploading '${zipFilename}' to Google Drive folder '${env.GOOGLE_DRIVE_FOLDER}'..."
|
||||||
powershell """
|
powershell """
|
||||||
rclone copy \"${zipFilename}\" remote:\"${env.GOOGLE_DRIVE_FOLDER}\"
|
rclone copy \"${zipFilename}\" ${remoteName}:${env.GOOGLE_DRIVE_FOLDER}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retention logic – keep only latest 5 ZIPs
|
// Retention: keep only latest 5
|
||||||
echo "Cleaning up old ZIP files in Google Drive..."
|
echo "Cleaning up old ZIP files in Google Drive..."
|
||||||
powershell """
|
powershell """
|
||||||
\$files = rclone lsf --files-only --format "t" --max-age 365d remote:\"${env.GOOGLE_DRIVE_FOLDER}\" | Sort-Object | Where-Object { \$_ -like "*.zip" }
|
\$files = rclone lsf --files-only ${remoteName}:${env.GOOGLE_DRIVE_FOLDER} | Sort-Object
|
||||||
if (\$files.Count -gt 5) {
|
if (\$files.Count -gt 5) {
|
||||||
\$filesToDelete = \$files | Select-Object -First (\$files.Count - 5)
|
\$filesToDelete = \$files | Select-Object -First (\$files.Count - 5)
|
||||||
foreach (\$file in \$filesToDelete) {
|
foreach (\$file in \$filesToDelete) {
|
||||||
rclone delete remote:\"${env.GOOGLE_DRIVE_FOLDER}/\$file\"
|
rclone delete ${remoteName}:${env.GOOGLE_DRIVE_FOLDER}/\$file
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user