From 5395ea418b341de0f8d29bc0c961000f70a07ed3 Mon Sep 17 00:00:00 2001 From: Roberto Cirillo Date: Fri, 6 May 2022 15:59:59 +0200 Subject: [PATCH] add git pull command --- Jenkinsfile | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 34208b4..1de35d3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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 + ''' +} \ No newline at end of file