From bb7eec1d5d594c4f320ef6ea7e86257bc92e3700 Mon Sep 17 00:00:00 2001 From: dzaitsev Date: Sun, 4 May 2025 15:33:23 +0300 Subject: [PATCH] latest fixes for Gdrive upload --- build/jenkins/GDriveUpload | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/build/jenkins/GDriveUpload b/build/jenkins/GDriveUpload index 8c6fa37..402ada9 100644 --- a/build/jenkins/GDriveUpload +++ b/build/jenkins/GDriveUpload @@ -55,13 +55,14 @@ pipeline { } } - stage('Upload to Google Drive using rclone') { + stage('Upload or Delete Local If Already Exists') { steps { echo "Checking if ${env.LATEST_ZIP_FILENAME} already exists on Google Drive..." powershell """ \$fileName = "${env.LATEST_ZIP_FILENAME}" \$folder = "${params.GOOGLE_DRIVE_FOLDER}" \$rcloneRemote = "AzaionGoogleDrive:\$folder" + \$localFilePath = "C:/Jenkins/workspace/AzaionSuite/suite/\$fileName" Write-Output "Checking for existing files in: \$rcloneRemote" \$existingFiles = rclone lsf --files-only \$rcloneRemote @@ -69,12 +70,17 @@ pipeline { Write-Output \$existingFiles if (\$existingFiles -match "^\$fileName\$") { - Write-Output "File '\$fileName' already exists on Google Drive. Skipping upload." + Write-Output "File '\$fileName' already exists on Google Drive. Deleting local copy..." + if (Test-Path \$localFilePath) { + Remove-Item -Force \$localFilePath + Write-Output "Local file deleted: \$localFilePath" + } else { + Write-Output "Local file not found for deletion: \$localFilePath" + } } else { Write-Output "Uploading '\$fileName' to Google Drive..." - \$filePath = "C:/Jenkins/workspace/AzaionSuite/suite/\$fileName" - \$env:RCLONE_CONFIG = 'C:/Program Files/rclone/rclone.conf' - rclone copy "\$filePath" \$rcloneRemote --progress --drive-chunk-size 64M + rclone copy "\$localFilePath" \$rcloneRemote --progress --drive-chunk-size 64M + Write-Output "Upload complete." } """ }