mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 11:36:31 +00:00
gdrive update1
This commit is contained in:
+18
-15
@@ -10,7 +10,7 @@ pipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
RCLONE_CONFIG = 'C:/Program Files/rclone/rclone.conf'
|
RCLONE_CONFIG = 'C:/Program Files/rclone/rclone.conf' // Ensure this points to the correct location
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
@@ -62,9 +62,12 @@ pipeline {
|
|||||||
\$filePath = "C:/Jenkins/workspace/AzaionSuite/suite/${env.LATEST_ZIP_FILENAME}"
|
\$filePath = "C:/Jenkins/workspace/AzaionSuite/suite/${env.LATEST_ZIP_FILENAME}"
|
||||||
Write-Output "Preparing to upload: \$filePath"
|
Write-Output "Preparing to upload: \$filePath"
|
||||||
|
|
||||||
|
# Display the contents of the rclone configuration file to ensure it's being read correctly
|
||||||
Get-Content 'C:/Program Files/rclone/rclone.conf'
|
Get-Content 'C:/Program Files/rclone/rclone.conf'
|
||||||
|
|
||||||
\$env:RCLONE_CONFIG = 'C:/Program Files/rclone/rclone.conf'
|
\$env:RCLONE_CONFIG = 'C:/Program Files/rclone/rclone.conf'
|
||||||
|
|
||||||
|
# Use rclone to upload the file to Google Drive
|
||||||
rclone copy "\$filePath" AzaionGoogleDrive:${params.GOOGLE_DRIVE_FOLDER} --progress --drive-chunk-size 64M
|
rclone copy "\$filePath" AzaionGoogleDrive:${params.GOOGLE_DRIVE_FOLDER} --progress --drive-chunk-size 64M
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
@@ -74,28 +77,28 @@ pipeline {
|
|||||||
steps {
|
steps {
|
||||||
echo "Cleaning up older files on Google Drive..."
|
echo "Cleaning up older files on Google Drive..."
|
||||||
powershell """
|
powershell """
|
||||||
Write-Output "Listing all files in the folder ${params.GOOGLE_DRIVE_FOLDER} on Google Drive..."
|
\$driveFolder = '${params.GOOGLE_DRIVE_FOLDER}'
|
||||||
\$files = rclone lsf --files-only AzaionGoogleDrive:${params.GOOGLE_DRIVE_FOLDER}
|
|
||||||
|
# List all files in the Google Drive folder
|
||||||
|
Write-Output "Listing all files in the folder \$driveFolder on Google Drive..."
|
||||||
|
\$files = rclone lsf AzaionGoogleDrive:\$driveFolder --files-only --max-depth 1
|
||||||
Write-Output "Files found on Google Drive:"
|
Write-Output "Files found on Google Drive:"
|
||||||
Write-Output \$files
|
Write-Output \$files
|
||||||
|
|
||||||
\$filesArray = \$files -split "`n" | Where-Object { \$_ -ne "" } | Sort-Object -Descending
|
if (\$files.Count -gt 0) {
|
||||||
|
\$filesSorted = \$files | Sort-Object -Descending
|
||||||
\$filesToDelete = \$filesArray | Select-Object -Skip 3
|
\$filesToDelete = \$filesSorted | Select-Object -Skip 3
|
||||||
|
|
||||||
Write-Output "Files to delete (older than 3 latest):"
|
Write-Output "Files to delete (older than 3 latest):"
|
||||||
Write-Output \$filesToDelete
|
Write-Output \$filesToDelete
|
||||||
|
|
||||||
if (\$filesToDelete.Count -gt 0) {
|
foreach (\$file in \$filesToDelete) {
|
||||||
\$tempFile = [System.IO.Path]::GetTempFileName()
|
\$trimmedFile = \$file.Trim()
|
||||||
\$filesToDelete | Out-File -FilePath \$tempFile -Encoding utf8
|
Write-Output "Deleting file: \$trimmedFile"
|
||||||
Write-Output "Contents of temporary delete list file (\$tempFile):"
|
rclone deletefile AzaionGoogleDrive:\$driveFolder/\$trimmedFile
|
||||||
Get-Content \$tempFile
|
}
|
||||||
rclone delete AzaionGoogleDrive:${params.GOOGLE_DRIVE_FOLDER} --files-from \$tempFile
|
|
||||||
|
|
||||||
Remove-Item -Path \$tempFile
|
|
||||||
} else {
|
} else {
|
||||||
Write-Output "No files to delete."
|
Write-Output "No files found on Google Drive to clean up."
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user