generated from gCubeCI/Pipeline-Docker-Template
add cleanup deploy file
This commit is contained in:
parent
d1bcc91df4
commit
00f1e7b869
|
@ -10,8 +10,10 @@
|
|||
|
||||
def agent_root_folder = '/var/lib/jenkins'
|
||||
def agent_deploy_filename = 'deploy.csv'
|
||||
def agent_deploy_backup_filename = 'deploy.bck'
|
||||
|
||||
def deployList
|
||||
def backupList
|
||||
if (params.deployFile) {
|
||||
println "Using custom deploy file"
|
||||
deployList = params.deployFile
|
||||
|
@ -21,6 +23,7 @@ if (params.deployFile) {
|
|||
deployList = agent_root_folder+'/'+agent_deploy_filename;
|
||||
println "Load from local file ${deployList}"
|
||||
}
|
||||
backupList = agent_root_folder+'/'+agent_deploy_backup_filename;
|
||||
|
||||
pipeline {
|
||||
agent {
|
||||
|
@ -40,6 +43,7 @@ pipeline {
|
|||
environment {
|
||||
AGENT_ROOT_FOLDER = "${agent_root_folder}"
|
||||
DEPLOY_FILE = "${agent_root_folder}/${agent_deploy_filename}"
|
||||
BACKUP_FILE = "${agent_root_folder}/${agent_deploy_backup_filename}"
|
||||
TRIGGER_JOB= "${params.TRIGGER_JOB}"
|
||||
TRIGGER_VERSION= "${params.TRIGGER_VERSION}"
|
||||
}
|
||||
|
@ -69,8 +73,16 @@ pipeline {
|
|||
for (component in components) {
|
||||
println "Deploy on going of component: $component"
|
||||
}
|
||||
new File(${DEPLOY_FILE}).delete();
|
||||
|
||||
}
|
||||
sh '''
|
||||
echo "cleanup $DEPLOY_FILE"
|
||||
if [ -f ${DEPLOY_BACKUP ]; then
|
||||
echo "backup found: $DEPLOY_BACKUP going to replace it"
|
||||
rm ${DEPLOY_BACKUP}
|
||||
mv $DEPLOY_FILE $DEPLOY_BACKUP
|
||||
touch $DEPLOY_FILE
|
||||
'''
|
||||
}
|
||||
}
|
||||
stage('Nothing to do by System ') {
|
||||
|
@ -95,6 +107,7 @@ pipeline {
|
|||
steps {
|
||||
sh '''
|
||||
echo "Cron build enabled. New deploy of ${TRIGGER_JOB} - ${TRIGGER_VERSION} will be added to the deploy file"
|
||||
|
||||
if grep -q \"\${TRIGGER_JOB}\" \${DEPLOY_FILE}; then
|
||||
echo "component ${TRIGGER_JOB} already added. Nothing to add."
|
||||
else
|
||||
|
@ -173,3 +186,17 @@ def appendToFile(String fileName, String line) {
|
|||
writeFile file: fileName, text: current + "\n" + line
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the footer to the deploy file.
|
||||
*/
|
||||
def appendFooter( def File) {
|
||||
def now = new Date()
|
||||
sh("""
|
||||
echo "" >> $File
|
||||
echo "---" >> $File
|
||||
echo "*generated by the gCubeDeploy pipeline >> $File
|
||||
echo "" >> $File
|
||||
echo "*last update $now*" >> $File
|
||||
""")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue