add loop on deploy folder

This commit is contained in:
Roberto Cirillo 2022-10-03 16:38:01 +02:00
parent f72d3705fb
commit 3b9e5e1826
1 changed files with 22 additions and 10 deletions

32
Jenkinsfile vendored
View File

@ -55,6 +55,7 @@ pipeline {
PIPELINE_BUILD_NUMBER = "${env.BUILD_NUMBER}"
DEPLOY_FILE = "${PENDING_DEPLOY_FOLDER}deploy.${PIPELINE_BUILD_NUMBER}.csv"
BACKUP_FILE = "${PENDING_DEPLOY_FOLDER}deploy.${PIPELINE_BUILD_NUMBER}.bck"
DEPLOY_FOLDER= "${WORKSPACE}/CD-${PIPELINE_BUILD_NUMBER}"
TRIGGER_JOB= "${params.TRIGGER_JOB}"
TRIGGER_VERSION= "${params.TRIGGER_VERSION}"
TRIGGER_HOST="${params.TRIGGER_HOST}"
@ -103,17 +104,28 @@ pipeline {
echo 'Cron build enabled. Deploy from system ongoing'
script {
println "Going to check the deploy file in ${PENDING_DEPLOY_FOLDER}"
def records = readCSV file: 'CD/deploy.csv'
for (def record : records) {
println("Processing record: "+record)
stage(record.get(0)){
println "Deploy on going of component: record.get(0)"
catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') {
checkup(record.get(0), record.get(1), record.get(2));
deploy(record.get(0), record.get(1), record.get(2));
// def records = readCSV file: 'CD/deploy.csv'
// def files = findFiles(glob: 'target/surefire-reports/*.csv')
def deployFolder="CD-${env.BUILD_NUMBER}";
println ("searching files in folder ${deployFolder}");
def files = findFiles(glob: "CD-${deployFolder}/*.csv")
for (def file : files){
echo """
Processing: ${files[0].name} ${files[0].path} ${files[0].directory}
${files[0].length} ${files[0].lastModified}
"""
def records = readCSV file: 'file.path'
for (def record : records) {
println("Processing record: "+record)
stage(record.get(0)){
println "Deploy on going of component: record.get(0)"
catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') {
checkup(record.get(0), record.get(1), record.get(2));
deploy(record.get(0), record.get(1), record.get(2));
}
}
}
}
}
}
}
cleanup(DEPLOY_FILE,BACKUP_FILE);
}