add TRIGGER_CD boolean parameter.

This commit is contained in:
Roberto Cirillo 2022-05-10 10:50:15 +02:00
parent c116e1265d
commit 6ca6c5ad89
1 changed files with 4 additions and 2 deletions

6
Jenkinsfile vendored
View File

@ -44,10 +44,12 @@ pipeline {
}
environment {
AGENT_ROOT_FOLDER = "${agent_root_folder}"
DEPLOY_ROOT_FOLDER ="${agent_root_folder}/ansible-repos/ansible-playbooks/d4science-ghn-cluster/"
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}"
TRIGGER_CD="${params.TRIGGER_CD}"
// maybe here define another param used to identify the target host. In this way the developer can change it from the job
}
stages {
@ -68,7 +70,6 @@ pipeline {
}
steps {
echo 'Cron build enabled. Deploy from system ongoing'
echo '\033[34mHello\033[0m \033[33mcolorful\033[0m \033[35mworld!\033[0m'
script {
// parse the report and extract the data
def components = parseCSVList(deployList)
@ -123,6 +124,7 @@ pipeline {
stage('Deploy from job ') {
when{
environment name: 'IS_CRON', value: 'False'
TRIGGER_CD;
anyOf{
triggeredBy 'BuildUpstreamCause'
triggeredBy 'UpstreamCause'
@ -214,7 +216,7 @@ 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);
def statusCode = sh( script: "cd /var/lib/jenkins/ansible-repos/ansible-playbooks/d4science-ghn-cluster/;git pull;cd CD;echo '\033[34mStarting\033[0m \033[33mAnsible\033[0m \033[35mWorld\033[0m';./deployService.sh $service $version $host;", returnStdout: true);
def statusCode = sh( script: "cd $DEPLOY_ROOT_FOLDER/;./deployService.sh $service $version $host;", returnStdout: true);
println("Deploy ended with status: "+statusCode);
sh("""
echo " last exit code \$?";