From 244797a151d5c4922faf39c93eb544081dd79746 Mon Sep 17 00:00:00 2001 From: "roberto.cirillo" Date: Mon, 10 Oct 2022 17:10:42 +0200 Subject: [PATCH] add condition in order to avoid job stages when the job is gCubeBuilder pipeline --- Jenkinsfile | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 201766b..cd6890c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -167,13 +167,15 @@ pipeline { } steps { sh ''' - echo "Cron build enabled. New deploy of ${TRIGGER_JOB} - ${TRIGGER_VERSION} will be added to the pending deploy file" - touch $DEPLOY_FILE; - if grep -q \"\${TRIGGER_JOB}\" \${DEPLOY_FILE}; then - echo "component ${TRIGGER_JOB} already added. Nothing to add." - else - echo "${TRIGGER_JOB},${TRIGGER_VERSION},${TRIGGER_HOST}" >> ${DEPLOY_FILE} - fi + if [ "${TRIGGER_JOB}" != 'gCubeBuilder' ] + echo "Cron build enabled. New deploy of ${TRIGGER_JOB} - ${TRIGGER_VERSION} will be added to the pending deploy file" + touch $DEPLOY_FILE; + if grep -q \"\${TRIGGER_JOB}\" \${DEPLOY_FILE}; then + echo "component ${TRIGGER_JOB} already added. Nothing to add." + else + echo "${TRIGGER_JOB},${TRIGGER_VERSION},${TRIGGER_HOST}" >> ${DEPLOY_FILE} + fi + fi ''' // the following catch give always an error in order to return a feedback UNSTABLE to the final user since the deploy is still not performed catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') { @@ -195,14 +197,19 @@ pipeline { } } steps { - echo "Cron build disabled. New deploy of ${params.TRIGGER_JOB} - ${params.TRIGGER_VERSION} ongoing" - ansiColor("xterm") { - catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { - checkup("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}"); - deploy("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}"); - } - } + script{ + if("${TRIGGER_JOB}" != 'gCubeBuilder'){ + echo "Cron build disabled. New deploy of ${params.TRIGGER_JOB} - ${params.TRIGGER_VERSION} ongoing" + ansiColor("xterm") { + catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { + checkup("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}"); + deploy("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}"); + } + } + } + } + } } stage('Deploy from gCubeRelease ') { @@ -210,6 +217,8 @@ pipeline { anyOf{ triggeredBy 'BuildUpstreamCause' triggeredBy 'UpstreamCause' + //added just for testing . To Remove. + triggeredBy 'UserIdCause' } // we should improve this conditional check equals(actual: "${params.TRIGGER_JOB}", expected: 'gCubeBuilder')