add function for service deploy

This commit is contained in:
Roberto Cirillo 2022-05-02 13:02:50 +02:00
parent ce05084684
commit 6c6ea2f5c2
1 changed files with 14 additions and 3 deletions

17
Jenkinsfile vendored
View File

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