From a9453e070752d00ad55a95350c30d9c90e373ba7 Mon Sep 17 00:00:00 2001 From: "roberto.cirillo" Date: Mon, 18 Jul 2022 10:08:09 +0200 Subject: [PATCH] merge conflicts --- Jenkinsfile | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bc68003..09d8c31 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,26 @@ 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') + string(name: 'report', + defaultValue: '', + description: 'The deploy report. Leave blank to pull the build report from Git.') + + } + stages { stage('Initialize environment') { steps { @@ -71,7 +99,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){ @@ -149,6 +177,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 { @@ -217,6 +263,7 @@ def checkup(String service, String version, String host){ sh(""" case "$version" in **SNAPSHOT) echo "version contains SNAPSHOT" ;; + **latest) echo "version contains latest" ;; * ) echo "version without SNAPSHOT. EXIT WITHOUT DEPLOY "; exit 1;; esac """)