mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:56:31 +00:00
pipelines zip and gdrive upload
updated
This commit is contained in:
+19
-10
@@ -32,10 +32,19 @@ pipeline {
|
|||||||
script {
|
script {
|
||||||
echo "Finding latest zip file in: C:/Jenkins/workspace/Azaion/suite"
|
echo "Finding latest zip file in: C:/Jenkins/workspace/Azaion/suite"
|
||||||
dir('C:/Jenkins/workspace/Azaion/suite') {
|
dir('C:/Jenkins/workspace/Azaion/suite') {
|
||||||
// Find the latest zip file using shell command
|
// Debug output to confirm current directory contents
|
||||||
def latestZip = bat(script: 'dir /b /od *.zip | findstr /r /c:"AzaionSuite.Iterative.*.zip"', returnStdout: true).trim()
|
echo "Listing .zip files in the directory:"
|
||||||
env.LATEST_ZIP_FILENAME = latestZip
|
bat(script: 'dir /b *.zip', returnStdout: true).trim()
|
||||||
echo "✅ Latest zip file selected: ${env.LATEST_ZIP_FILENAME}"
|
|
||||||
|
// 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 """
|
powershell """
|
||||||
# Check if file exists on Google Drive
|
# Check if file exists on Google Drive
|
||||||
\$existingFiles = rclone lsf --files-only AzaionGoogleDrive:${GOOGLE_DRIVE_FOLDER}
|
\$existingFiles = rclone lsf --files-only AzaionGoogleDrive:${GOOGLE_DRIVE_FOLDER}
|
||||||
if (\$existingFiles -contains "${env.LATEST_ZIP_FILENAME}") {
|
if (\$existingFiles -contains "${LATEST_ZIP_FILENAME}") {
|
||||||
Write-Output "File ${env.LATEST_ZIP_FILENAME} already exists on Google Drive, skipping upload."
|
Write-Output "File ${LATEST_ZIP_FILENAME} already exists on Google Drive, skipping upload."
|
||||||
} else {
|
} else {
|
||||||
Write-Output "Uploading ${env.LATEST_ZIP_FILENAME} to Google Drive..."
|
Write-Output "Uploading ${LATEST_ZIP_FILENAME} to Google Drive..."
|
||||||
rclone copy C:/Jenkins/workspace/Azaion/suite/${env.LATEST_ZIP_FILENAME} AzaionGoogleDrive:${GOOGLE_DRIVE_FOLDER}
|
rclone copy C:/Jenkins/workspace/Azaion/suite/${LATEST_ZIP_FILENAME} AzaionGoogleDrive:${GOOGLE_DRIVE_FOLDER}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Always remove the local file after uploading
|
# 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
|
# Split files by line and exclude the latest zip file
|
||||||
\$filesArray = \$files -split "`n" | Where-Object { \$_ -ne "" }
|
\$filesArray = \$files -split "`n" | Where-Object { \$_ -ne "" }
|
||||||
\$latestFile = "${env.LATEST_ZIP_FILENAME}"
|
\$latestFile = "${LATEST_ZIP_FILENAME}"
|
||||||
\$filesArray = \$filesArray | Where-Object { \$_ -ne \$latestFile }
|
\$filesArray = \$filesArray | Where-Object { \$_ -ne \$latestFile }
|
||||||
|
|
||||||
# If more than 3 files exist, delete the oldest ones
|
# If more than 3 files exist, delete the oldest ones
|
||||||
|
|||||||
Reference in New Issue
Block a user