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 { steps {
echo "Checking if ${env.LATEST_ZIP_FILENAME} already exists on Google Drive..." echo "Checking if ${env.LATEST_ZIP_FILENAME} already exists on Google Drive..."
powershell """ powershell """
\$fileName = "${env.LATEST_ZIP_FILENAME}" \$fileName = "${env.LATEST_ZIP_FILENAME}"
\$folder = "${params.GOOGLE_DRIVE_FOLDER}" \$folder = "${params.GOOGLE_DRIVE_FOLDER}"
\$rcloneRemote = "AzaionGoogleDrive:\$folder" \$rcloneRemote = "AzaionGoogleDrive:\$folder"
\$localFilePath = "C:/Jenkins/workspace/AzaionSuite/suite/\$fileName"
Write-Output "Checking for existing files in: \$rcloneRemote" Write-Output "Checking for existing files in: \$rcloneRemote"
\$existingFiles = rclone lsf --files-only \$rcloneRemote \$existingFiles = rclone lsf --files-only \$rcloneRemote
@@ -69,12 +70,17 @@ pipeline {
Write-Output \$existingFiles Write-Output \$existingFiles
if (\$existingFiles -match "^\$fileName\$") { 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 { } else {
Write-Output "Uploading '\$fileName' to Google Drive..." Write-Output "Uploading '\$fileName' to Google Drive..."
\$filePath = "C:/Jenkins/workspace/AzaionSuite/suite/\$fileName" rclone copy "\$localFilePath" \$rcloneRemote --progress --drive-chunk-size 64M
\$env:RCLONE_CONFIG = 'C:/Program Files/rclone/rclone.conf' Write-Output "Upload complete."
rclone copy "\$filePath" \$rcloneRemote --progress --drive-chunk-size 64M
} }
""" """
} }