diff --git a/build/jenkins/GDriveUpload b/build/jenkins/GDriveUpload index 278e03b..5ebb9a0 100644 --- a/build/jenkins/GDriveUpload +++ b/build/jenkins/GDriveUpload @@ -32,7 +32,8 @@ pipeline { script { echo "Finding latest zip file in: C:/Jenkins/workspace/Azaion/suite" dir('C:/Jenkins/workspace/Azaion/suite') { - def latestZip = sh(script: 'ls -t *.zip | head -n 1', returnStdout: true).trim() + // 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() env.LATEST_ZIP_FILENAME = latestZip echo "✅ Latest zip file selected: ${env.LATEST_ZIP_FILENAME}" } @@ -46,15 +47,15 @@ pipeline { powershell """ # Check if file exists on Google Drive \$existingFiles = rclone lsf --files-only AzaionGoogleDrive:${GOOGLE_DRIVE_FOLDER} - if (\$existingFiles -contains "${LATEST_ZIP_FILENAME}") { - Write-Output "File ${LATEST_ZIP_FILENAME} already exists on Google Drive, skipping upload." + if (\$existingFiles -contains "${env.LATEST_ZIP_FILENAME}") { + Write-Output "File ${env.LATEST_ZIP_FILENAME} already exists on Google Drive, skipping upload." } else { - Write-Output "Uploading ${LATEST_ZIP_FILENAME} to Google Drive..." - rclone copy C:/Jenkins/workspace/Azaion/suite/${LATEST_ZIP_FILENAME} AzaionGoogleDrive:${GOOGLE_DRIVE_FOLDER} + 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} } # Always remove the local file after uploading - Remove-Item "C:/Jenkins/workspace/Azaion/suite/${LATEST_ZIP_FILENAME}" + Remove-Item "C:/Jenkins/workspace/Azaion/suite/${env.LATEST_ZIP_FILENAME}" """ } } @@ -77,7 +78,7 @@ pipeline { # Split files by line and exclude the latest zip file \$filesArray = \$files -split "`n" | Where-Object { \$_ -ne "" } - \$latestFile = "${LATEST_ZIP_FILENAME}" + \$latestFile = "${env.LATEST_ZIP_FILENAME}" \$filesArray = \$filesArray | Where-Object { \$_ -ne \$latestFile } # If more than 3 files exist, delete the oldest ones @@ -112,13 +113,6 @@ pipeline { """ } } - - stage('Declarative: Post Actions') { - steps { - echo "Executing post-build cleanup..." - // Clean up any resources after the pipeline run - } - } } post {