pipelines zip and gdrive upload

updated
This commit is contained in:
dzaitsev
2025-05-07 19:33:44 +03:00
parent 5c3fa80a17
commit 81620888f2
+17 -8
View File
@@ -32,10 +32,19 @@ pipeline {
script {
echo "Finding latest zip file in: C:/Jenkins/workspace/Azaion/suite"
dir('C:/Jenkins/workspace/Azaion/suite') {
// Find the latest zip file using shell command
def latestZip = bat(script: 'dir /b /od *.zip | findstr /r /c:"AzaionSuite.Iterative.*.zip"', returnStdout: true).trim()
// Debug output to confirm current directory contents
echo "Listing .zip files in the directory:"
bat(script: 'dir /b *.zip', returnStdout: true).trim()
// Get the most recent .zip file based on modification date
def latestZip = bat(script: 'dir /b /od *.zip | head -n 1', returnStdout: true).trim()
if (latestZip) {
env.LATEST_ZIP_FILENAME = latestZip
echo "✅ Latest zip file selected: ${env.LATEST_ZIP_FILENAME}"
} else {
error "No valid zip files found in the directory!"
}
}
}
}
@@ -47,15 +56,15 @@ pipeline {
powershell """
# Check if file exists on Google Drive
\$existingFiles = rclone lsf --files-only AzaionGoogleDrive:${GOOGLE_DRIVE_FOLDER}
if (\$existingFiles -contains "${env.LATEST_ZIP_FILENAME}") {
Write-Output "File ${env.LATEST_ZIP_FILENAME} already exists on Google Drive, skipping upload."
if (\$existingFiles -contains "${LATEST_ZIP_FILENAME}") {
Write-Output "File ${LATEST_ZIP_FILENAME} already exists on Google Drive, skipping upload."
} else {
Write-Output "Uploading ${env.LATEST_ZIP_FILENAME} to Google Drive..."
rclone copy C:/Jenkins/workspace/Azaion/suite/${env.LATEST_ZIP_FILENAME} AzaionGoogleDrive:${GOOGLE_DRIVE_FOLDER}
Write-Output "Uploading ${LATEST_ZIP_FILENAME} to Google Drive..."
rclone copy C:/Jenkins/workspace/Azaion/suite/${LATEST_ZIP_FILENAME} AzaionGoogleDrive:${GOOGLE_DRIVE_FOLDER}
}
# Always remove the local file after uploading
Remove-Item "C:/Jenkins/workspace/Azaion/suite/${env.LATEST_ZIP_FILENAME}"
Remove-Item "C:/Jenkins/workspace/Azaion/suite/${LATEST_ZIP_FILENAME}"
"""
}
}
@@ -78,7 +87,7 @@ pipeline {
# Split files by line and exclude the latest zip file
\$filesArray = \$files -split "`n" | Where-Object { \$_ -ne "" }
\$latestFile = "${env.LATEST_ZIP_FILENAME}"
\$latestFile = "${LATEST_ZIP_FILENAME}"
\$filesArray = \$filesArray | Where-Object { \$_ -ne \$latestFile }
# If more than 3 files exist, delete the oldest ones