latest fixes for Gdrive upload

This commit is contained in:
dzaitsev
2025-05-04 15:33:23 +03:00
parent 7fc51e19ee
commit bb7eec1d5d
+11 -5
View File
@@ -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."
}
"""
}