From 6c6ea2f5c2d842038b51af25e33333a71659f1b2 Mon Sep 17 00:00:00 2001 From: Roberto Cirillo Date: Mon, 2 May 2022 13:02:50 +0200 Subject: [PATCH] add function for service deploy --- Jenkinsfile | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ab75a33..018d22b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -34,9 +34,10 @@ pipeline { // cron('H/15 * * * *') // once a day on the 1st and 15th of every month cron ('H H 1,15 * *') +// once in every two hours slot between 9 AM and 5 PM every weekday (perhaps at 10:38 AM, 12:38 PM, 2:38 PM, 4:38 PM) +// cron('H H(9-16)/2 * * 1-5') + } - //once in every two hours slot between 9 AM and 5 PM every weekday (perhaps at 10:38 AM, 12:38 PM, 2:38 PM, 4:38 PM) -// cron('H H(9-16)/2 * * 1-5') environment { AGENT_ROOT_FOLDER = "${agent_root_folder}" DEPLOY_FILE = "${agent_root_folder}/${agent_deploy_filename}" @@ -71,6 +72,7 @@ pipeline { stage(component){ println "Deploy on going of component: $component" catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + // calling the ansible dispatcher here sh "exit 0" } } @@ -135,7 +137,7 @@ pipeline { steps { echo "Cron build disabled. New deploy of ${params.TRIGGER_JOB} - ${params.TRIGGER_VERSION} ongoing" catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { - sh "exit 0" + deployService(${params.TRIGGER_JOB}, ${params.TRIGGER_VERSION}, ${params.TRIGGER_HOST) } } @@ -212,3 +214,12 @@ def appendFooter( def File) { """) } + +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/; + ./deployService..sh $service $version $host + """) +}