From 4f2aeb59200c807f81b4ce953c07834811c15815 Mon Sep 17 00:00:00 2001 From: Roberto Cirillo Date: Tue, 21 Jun 2022 15:47:38 +0200 Subject: [PATCH] add input parameters in order to launch the pipeline manually; add new stage dedicated to the manually execution --- Jenkinsfile | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bf4f368..ddf305a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,6 +25,15 @@ if (params.deployFile) { } backupList = agent_root_folder+'/'+agent_deploy_backup_filename; +//locate the targetHost file +//String targetHostURL = "https://code-repo.d4science.org/gCubeCI/gCubeDeployer/raw/branch/master/open/gcube-${gCube_release_version}.yaml" +//if (verbose) +// println "Querying ${targetHostURL}" +//load the release file +//def text = targetHostURL.toURL().getText() + + + pipeline { agent { label 'CD' @@ -50,7 +59,23 @@ pipeline { TRIGGER_HOST="${params.TRIGGER_HOST}" TRIGGER_CD="${params.TRIGGER_CD}" } - + + parameters { + string(name: 'TRIGGER_JOB', + defaultValue: '', + description: 'Name of the service or job to deploy') + string(name: 'TRIGGER_VERSION', + defaultValue: '', + description: 'service version to deploy') + string(name: 'TRIGGER_HOST', + defaultValue: '', + description: 'Target Host / Host group where deploy the service') + booleanParam(name: 'TRIGGER_CD', + defaultValue: true, + description: 'Set to false to avoid current deploy') + + } + stages { stage('Initialize environment') { steps { @@ -71,7 +96,7 @@ pipeline { echo 'Cron build enabled. Deploy from system ongoing' script { // parse the report and extract the data - def components = gettComponentsFromCSV(deployList) + def components = getComponentsFromCSV(deployList) if (components.size() > 0) { for (component in components) { stage(component){ @@ -147,6 +172,24 @@ pipeline { } } + stage('Deploy manually ') { + when{ + allOf{ + environment name: 'IS_CRON', value: 'False'; + triggeredBy 'UserIdCause' + } + } + steps { + echo "Cron build disabled. Pipeline executed Manually. New deploy of ${params.TRIGGER_JOB} - ${params.TRIGGER_VERSION} ongoing" + ansiColor("xterm") { + catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { + checkup("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}"); + deploy("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}"); + } + } + + } + } } post { always {