From 3e41dac45c7ca1beeb1c7ee397ecc2bd606d840a Mon Sep 17 00:00:00 2001 From: Roberto Cirillo Date: Thu, 4 Aug 2022 10:13:03 +0200 Subject: [PATCH] add build number to every deploy file. Delete the file after processing it --- Jenkinsfile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 30699d5..930f0c5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,8 +9,8 @@ import groovy.io.FileType // related jenkins job: https://jenkins.d4science.org/job/gCubeDeployer/ def agent_root_folder = '/var/lib/jenkins' -def agent_deploy_filename = 'deploy.csv' -def agent_deploy_backup_filename = 'deploy.bck' +def agent_deploy_filename = 'deploy.${env.BUILD_NUMBER}.csv' +def agent_deploy_backup_filename = 'deploy.${env.BUILD_NUMBER}.bck' def deployList def backupList @@ -52,6 +52,7 @@ pipeline { environment { AGENT_ROOT_FOLDER = "${agent_root_folder}" DEPLOY_ROOT_FOLDER ="${agent_root_folder}/ansible-repos/ansible-playbooks/d4science-ghn-cluster/CD" + PIPELINE_BUILD_NUMBER = "${env.BUILD_NUMBER}" DEPLOY_FILE = "${agent_root_folder}/${agent_deploy_filename}" BACKUP_FILE = "${agent_root_folder}/${agent_deploy_backup_filename}" TRIGGER_JOB= "${params.TRIGGER_JOB}" @@ -99,7 +100,9 @@ pipeline { echo 'Cron build enabled. Deploy from system ongoing' script { // parse the report and extract the data - def components = getComponentsFromCSV(deployList) + // def components = getComponentsFromCSV(deployList) + println "Going to check the deploy file in ${DEPLOY_ROOT_FOLDER}" + def components =getComponentsFromCSVDir("${DEPLOY_ROOT_FOLDER}") if (components.size() > 0) { for (component in components) { stage(component){ @@ -306,8 +309,9 @@ def getComponentsFromCSVDir(def dirPath){ ] ) } - } + // remove the file here if possible + file.delete(); } return components } \ No newline at end of file