add git pull command

This commit is contained in:
Roberto Cirillo 2022-05-06 15:59:59 +02:00
parent 9326d444cf
commit 5395ea418b
1 changed files with 19 additions and 13 deletions

32
Jenkinsfile vendored
View File

@ -81,18 +81,7 @@ pipeline {
println "No components found"
}
}
sh '''
echo "cleanup $DEPLOY_FILE";
if [ -f ${DEPLOY_FILE} ]; then
if [ -f ${BACKUP_FILE} ]; then
echo "backup found: ${BACKUP_FILE} going to replace it";
rm ${BACKUP_FILE};
fi
mv ${DEPLOY_FILE} ${BACKUP_FILE};
else
echo "deploy file empty"
fi
'''
cleanup(DEPLOY_FILE,BACKUP_FILE);
}
}
stage('Nothing to do by System ') {
@ -219,7 +208,24 @@ def deploy(String service, String version, String host){
def now = new Date();
println("Going to deploy the service "+service+" with version: "+version+" on target: "+host);
sh("""
cd /var/lib/jenkins/ansible-repos/ansible-playbooks/d4science-ghn-cluster/CD/;
cd /var/lib/jenkins/ansible-repos/ansible-playbooks/d4science-ghn-cluster/;
git pull;
cd CD;
./deployService..sh $service $version $host
""")
}
def cleanup(def DEPLOY_FILE, def BACKUP_FILE){
sh '''
echo "cleanup $DEPLOY_FILE";
if [ -f ${DEPLOY_FILE} ]; then
if [ -f ${BACKUP_FILE} ]; then
echo "backup found: ${BACKUP_FILE} going to replace it";
rm ${BACKUP_FILE};
fi
mv ${DEPLOY_FILE} ${BACKUP_FILE};
else
echo "deploy file empty"
fi
'''
}