add build number to every deploy file. Delete the file after processing it

This commit is contained in:
Roberto Cirillo 2022-08-04 10:13:03 +02:00
parent 2485ec13c8
commit 3e41dac45c
1 changed files with 8 additions and 4 deletions

12
Jenkinsfile vendored
View File

@ -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
}