mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 08:36:29 +00:00
latest fixes for Gdrive upload
This commit is contained in:
+12
-12
@@ -26,10 +26,10 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Find Latest Zip and Upload') {
|
stage('Find Latest Zip') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
echo "Starting 'Find Latest Zip and Upload' stage."
|
echo "Finding latest zip file..."
|
||||||
dir("C:/Jenkins/workspace/AzaionSuite/suite") {
|
dir("C:/Jenkins/workspace/AzaionSuite/suite") {
|
||||||
def output = powershell(returnStdout: true, script: '''
|
def output = powershell(returnStdout: true, script: '''
|
||||||
$pattern = "AzaionSuite*-*-*.zip"
|
$pattern = "AzaionSuite*-*-*.zip"
|
||||||
@@ -48,16 +48,15 @@ pipeline {
|
|||||||
}
|
}
|
||||||
def zipFileName = match[0][1]
|
def zipFileName = match[0][1]
|
||||||
echo "Latest zip file selected: ${zipFileName}"
|
echo "Latest zip file selected: ${zipFileName}"
|
||||||
|
|
||||||
env.LATEST_ZIP_FILENAME = zipFileName
|
env.LATEST_ZIP_FILENAME = zipFileName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Upload or Delete Local If Already Exists') {
|
stage('Upload If Not Exists & Always Remove Local') {
|
||||||
steps {
|
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 """
|
powershell """
|
||||||
\$fileName = "${env.LATEST_ZIP_FILENAME}"
|
\$fileName = "${env.LATEST_ZIP_FILENAME}"
|
||||||
\$folder = "${params.GOOGLE_DRIVE_FOLDER}"
|
\$folder = "${params.GOOGLE_DRIVE_FOLDER}"
|
||||||
@@ -70,18 +69,19 @@ pipeline {
|
|||||||
Write-Output \$existingFiles
|
Write-Output \$existingFiles
|
||||||
|
|
||||||
if (\$existingFiles -match "^\$fileName\$") {
|
if (\$existingFiles -match "^\$fileName\$") {
|
||||||
Write-Output "File '\$fileName' already exists on Google Drive. Deleting local copy..."
|
Write-Output "File '\$fileName' already exists on Google Drive. Skipping upload."
|
||||||
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..."
|
||||||
rclone copy "\$localFilePath" \$rcloneRemote --progress --drive-chunk-size 64M
|
rclone copy "\$localFilePath" \$rcloneRemote --progress --drive-chunk-size 64M
|
||||||
Write-Output "Upload complete."
|
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."
|
||||||
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user