updated zip pipeline to use parameters from Azaion pipeline.

This commit is contained in:
dzaitsev
2025-05-07 18:22:51 +03:00
parent 961c750f1f
commit d5e7a28964
+11 -10
View File
@@ -1,6 +1,10 @@
pipeline { pipeline {
agent { label 'Win10-BuildMachine' } agent { label 'Win10-BuildMachine' }
parameters {
string(name: 'buildPath', defaultValue: 'C:/Jenkins/workspace/AzaionSuite/suite', description: 'Build directory to zip from')
}
tools { tools {
git 'Default' git 'Default'
} }
@@ -9,7 +13,6 @@ pipeline {
SEVEN_ZIP_PATH = "C:/Program Files/7-Zip" SEVEN_ZIP_PATH = "C:/Program Files/7-Zip"
PATH = "${SEVEN_ZIP_PATH};${env.PATH}" PATH = "${SEVEN_ZIP_PATH};${env.PATH}"
GOOGLE_DRIVE_UPLOAD_JOB_NAME = 'GDrive Upload' GOOGLE_DRIVE_UPLOAD_JOB_NAME = 'GDrive Upload'
MAIN_BUILD_ARTIFACTS_DIR = 'C:/Jenkins/workspace/AzaionSuite/suite'
} }
stages { stages {
@@ -17,11 +20,11 @@ pipeline {
steps { steps {
script { script {
echo "Starting 'Detect or Create Zip' stage." echo "Starting 'Detect or Create Zip' stage."
dir("${env.MAIN_BUILD_ARTIFACTS_DIR}") { echo "Using build path: ${params.buildPath}"
dir("${params.buildPath}") {
powershell ''' powershell '''
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
$sevenZipExe = "$env:SEVEN_ZIP_PATH\\7z.exe" $sevenZipExe = "$env:SEVEN_ZIP_PATH\\7z.exe"
$defaultVersion = "1.0.0"
$exePattern = "AzaionSuite*.exe" $exePattern = "AzaionSuite*.exe"
$binPattern = "AzaionSuite*.bin" $binPattern = "AzaionSuite*.bin"
$zipPattern = "AzaionSuite*.zip" $zipPattern = "AzaionSuite*.zip"
@@ -66,18 +69,16 @@ pipeline {
Write-Host "Created new zip file: $zipFilename" Write-Host "Created new zip file: $zipFilename"
} }
# Save outputs without BOM
Set-Content -Path "zipfilename.txt" -Value $zipFilename -Encoding ASCII Set-Content -Path "zipfilename.txt" -Value $zipFilename -Encoding ASCII
Set-Content -Path "zip_created.txt" -Value $wasCreated -Encoding ASCII Set-Content -Path "zip_was_created.txt" -Value $wasCreated -Encoding ASCII
''' '''
def zipFilename = readFile('zipfilename.txt').trim() def zipFilename = readFile('zipfilename.txt').trim()
def zipCreated = readFile('zip_created.txt').trim().toBoolean() def zipCreated = readFile('zip_was_created.txt').trim().toBoolean()
echo "Zip filename: ${zipFilename}" echo "Zip filename: ${zipFilename}"
echo "Was zip created this run? ${zipCreated}" echo "Was zip created this run? ${zipCreated}"
// Save results for next stages
writeFile file: 'created_zip.txt', text: zipFilename writeFile file: 'created_zip.txt', text: zipFilename
writeFile file: 'zip_was_created.txt', text: zipCreated.toString() writeFile file: 'zip_was_created.txt', text: zipCreated.toString()
} }
@@ -88,14 +89,14 @@ pipeline {
stage('Archive Zip File (if new)') { stage('Archive Zip File (if new)') {
when { when {
expression { expression {
def zipCreated = readFile("${env.MAIN_BUILD_ARTIFACTS_DIR}/zip_was_created.txt").trim().toBoolean() def zipCreated = readFile("${params.buildPath}/zip_was_created.txt").trim().toBoolean()
return zipCreated return zipCreated
} }
} }
steps { steps {
script { script {
echo "Archiving newly created zip file..." echo "Archiving newly created zip file..."
dir("${env.MAIN_BUILD_ARTIFACTS_DIR}") { dir("${params.buildPath}") {
def zipFilename = readFile('created_zip.txt').trim() def zipFilename = readFile('created_zip.txt').trim()
if (!fileExists(zipFilename)) { if (!fileExists(zipFilename)) {
error "Zip file '${zipFilename}' not found!" error "Zip file '${zipFilename}' not found!"
@@ -119,7 +120,7 @@ pipeline {
post { post {
success { success {
script { script {
def zipFilename = readFile("${env.MAIN_BUILD_ARTIFACTS_DIR}/created_zip.txt").trim() def zipFilename = readFile("${params.buildPath}/created_zip.txt").trim()
echo "Pipeline completed successfully. Final zip: ${zipFilename}" echo "Pipeline completed successfully. Final zip: ${zipFilename}"
} }
} }