latest fixes for Gdrive upload

This commit is contained in:
dzaitsev
2025-05-04 15:39:03 +03:00
parent bb7eec1d5d
commit 2766be732d
+12 -12
View File
@@ -26,10 +26,10 @@ pipeline {
}
}
stage('Find Latest Zip and Upload') {
stage('Find Latest Zip') {
steps {
script {
echo "Starting 'Find Latest Zip and Upload' stage."
echo "Finding latest zip file..."
dir("C:/Jenkins/workspace/AzaionSuite/suite") {
def output = powershell(returnStdout: true, script: '''
$pattern = "AzaionSuite*-*-*.zip"
@@ -48,16 +48,15 @@ pipeline {
}
def zipFileName = match[0][1]
echo "Latest zip file selected: ${zipFileName}"
env.LATEST_ZIP_FILENAME = zipFileName
}
}
}
}
stage('Upload or Delete Local If Already Exists') {
stage('Upload If Not Exists & Always Remove Local') {
steps {
echo "Checking if ${env.LATEST_ZIP_FILENAME} already exists on Google Drive..."
echo "Checking Google Drive for existing ZIP and uploading if needed..."
powershell """
\$fileName = "${env.LATEST_ZIP_FILENAME}"
\$folder = "${params.GOOGLE_DRIVE_FOLDER}"
@@ -70,18 +69,19 @@ pipeline {
Write-Output \$existingFiles
if (\$existingFiles -match "^\$fileName\$") {
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"
}
Write-Output "File '\$fileName' already exists on Google Drive. Skipping upload."
} else {
Write-Output "Uploading '\$fileName' to Google Drive..."
rclone copy "\$localFilePath" \$rcloneRemote --progress --drive-chunk-size 64M
Write-Output "Upload complete."
}
if (Test-Path \$localFilePath) {
Remove-Item -Force \$localFilePath
Write-Output "Local file deleted: \$localFilePath"
} else {
Write-Output "Local file already deleted or not found."
}
"""
}
}