add foo input parameter

This commit is contained in:
Roberto Cirillo 2024-02-23 16:06:41 +01:00
parent 8a95929a8a
commit 693c528411
2 changed files with 413 additions and 5 deletions

15
Jenkinsfile vendored
View File

@ -71,6 +71,8 @@ pipeline {
TRIGGER_HOST="${params.TRIGGER_HOST}" TRIGGER_HOST="${params.TRIGGER_HOST}"
// enable the ContinuousDeployment if TRUE // enable the ContinuousDeployment if TRUE
TRIGGER_CD="${params.TRIGGER_CD}" TRIGGER_CD="${params.TRIGGER_CD}"
// generic parameter that can be passed to the ansible job
TRIGGER_FOO="${params.TRIGGER_FOO}"
// Useful to identify the remote YAML file // Useful to identify the remote YAML file
GCUBE_RELEASE_NUMBER = "${params.gCube_release_version}" GCUBE_RELEASE_NUMBER = "${params.gCube_release_version}"
//Category name of the components candidates to the remote deployment //Category name of the components candidates to the remote deployment
@ -100,6 +102,9 @@ pipeline {
booleanParam(name: 'TRIGGER_CD', booleanParam(name: 'TRIGGER_CD',
defaultValue: true, defaultValue: true,
description: 'Set to false to avoid current deploy') description: 'Set to false to avoid current deploy')
string(name: 'TRIGGER_FOO',
defaultValue: '',
description: 'Additional parameter to pass to the ansible job. Leave blank if not used')
string(name: 'gCube_release_version', string(name: 'gCube_release_version',
defaultValue: '', defaultValue: '',
description: 'The number of the current gCube release. Leave blank if executed outside gCube release.') description: 'The number of the current gCube release. Leave blank if executed outside gCube release.')
@ -200,7 +205,7 @@ pipeline {
ansiColor('xterm') { ansiColor('xterm') {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
checkup("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}"); checkup("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}");
deploy("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}"); deploy("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}", "${params.TRIGGER_FOO}");
} }
} }
} }
@ -240,7 +245,7 @@ pipeline {
echo '\033[31;1;4mNew deploy ongoing manually triggered\033[0m' echo '\033[31;1;4mNew deploy ongoing manually triggered\033[0m'
echo "Cron build disabled. Pipeline executed Manually. New deploy of ${params.TRIGGER_JOB} - ${params.TRIGGER_VERSION} ongoing" echo "Cron build disabled. Pipeline executed Manually. New deploy of ${params.TRIGGER_JOB} - ${params.TRIGGER_VERSION} ongoing"
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
deploy("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}"); deploy("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}", "${params.TRIGGER_FOO}");
} }
} }
} }
@ -337,10 +342,10 @@ def deployJobs(def serviceList){
} }
//Run ansible deploy //Run ansible deploy
def deploy(String service, String version, String host){ def deploy(String service, String version, String host, String foo){
def now = new Date(); def now = new Date();
println("Going to deploy the service "+service+" with version: "+version+" on target: "+host); println("Going to deploy the service "+service+" with version: "+version+" on target: "+host+" with argument: "+foo);
def statusCode = sh( script: "cd ${ANSIBLE_ROOT_FOLDER}/CD;./deployService.sh $service $version $host;", returnStdout: true); def statusCode = sh( script: "cd ${ANSIBLE_ROOT_FOLDER}/CD;./deployService.sh $service $version $host $foo;", returnStdout: true);
sh(""" sh("""
echo " last exit code \$?"; echo " last exit code \$?";
""") """)

403
README.html Normal file

File diff suppressed because one or more lines are too long