replace gCubeBuilder string with RELEASE_JOB var

This commit is contained in:
Roberto Cirillo 2022-10-11 10:47:22 +02:00
parent c9dee5146a
commit 928bbfa138
1 changed files with 18 additions and 48 deletions

38
Jenkinsfile vendored
View File

@ -103,12 +103,6 @@ pipeline {
string(name: 'RELEASE_URL', string(name: 'RELEASE_URL',
defaultValue: '', defaultValue: '',
description: 'URL to the yaml file. Leave blank if executed outside gCube release.') description: 'URL to the yaml file. Leave blank if executed outside gCube release.')
// string(name: 'report',
// defaultValue: '',
// description: 'The build report. Leave blank to pull the build report from Git. Leave blank if executed outside gCube release.')
} }
stages { stages {
@ -163,13 +157,13 @@ pipeline {
anyOf{ anyOf{
triggeredBy 'BuildUpstreamCause' triggeredBy 'BuildUpstreamCause'
triggeredBy 'UpstreamCause' triggeredBy 'UpstreamCause'
// this condition should be deleted. This is active only for testing purpose
triggeredBy 'UserIdCause' triggeredBy 'UserIdCause'
} }
expression { params.TRIGGER_JOB != 'gCubeBuilder' } expression { params.TRIGGER_JOB != "${RELEASE_JOB}" }
} }
steps { steps {
sh ''' sh '''
if [ "${TRIGGER_JOB}" != 'gCubeBuilder' ]; then
echo "Cron build enabled. New deploy of ${TRIGGER_JOB} - ${TRIGGER_VERSION} will be added to the pending deploy file" echo "Cron build enabled. New deploy of ${TRIGGER_JOB} - ${TRIGGER_VERSION} will be added to the pending deploy file"
touch $DEPLOY_FILE; touch $DEPLOY_FILE;
if grep -q \"\${TRIGGER_JOB}\" \${DEPLOY_FILE}; then if grep -q \"\${TRIGGER_JOB}\" \${DEPLOY_FILE}; then
@ -177,7 +171,6 @@ pipeline {
else else
echo "${TRIGGER_JOB},${TRIGGER_VERSION},${TRIGGER_HOST}" >> ${DEPLOY_FILE} echo "${TRIGGER_JOB},${TRIGGER_VERSION},${TRIGGER_HOST}" >> ${DEPLOY_FILE}
fi 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 // 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') { catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') {
@ -197,10 +190,10 @@ pipeline {
triggeredBy 'BuildUpstreamCause' triggeredBy 'BuildUpstreamCause'
triggeredBy 'UpstreamCause' triggeredBy 'UpstreamCause'
} }
expression { params.TRIGGER_JOB != "${RELEASE_JOB}" }
} }
steps { steps {
script{ script{
if("${TRIGGER_JOB}" != 'gCubeBuilder'){
echo "Cron build disabled. New deploy of ${params.TRIGGER_JOB} - ${params.TRIGGER_VERSION} ongoing" echo "Cron build disabled. New deploy of ${params.TRIGGER_JOB} - ${params.TRIGGER_VERSION} ongoing"
ansiColor("xterm") { ansiColor("xterm") {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
@ -209,7 +202,6 @@ pipeline {
} }
} }
} }
}
} }
@ -223,7 +215,7 @@ pipeline {
triggeredBy 'UserIdCause' triggeredBy 'UserIdCause'
} }
// we should improve this conditional check // we should improve this conditional check
equals(actual: "${params.TRIGGER_JOB}", expected: 'gCubeBuilder') equals(actual: "${params.TRIGGER_JOB}", expected: "${RELEASE_JOB}")
} }
steps { steps {
script{ script{
@ -237,8 +229,6 @@ pipeline {
} }
deployReleaseJobs(releaseList); deployReleaseJobs(releaseList);
} }
} }
} }
stage('Deploy manually ') { stage('Deploy manually ') {
@ -265,7 +255,6 @@ pipeline {
sh ''' sh '''
echo 'Sending report' echo 'Sending report'
''' '''
//cat ./${ACTION_DEPLOY_FILE}.csv
} }
} }
success { success {
@ -416,22 +405,3 @@ def deployReleaseJobs(def serviceList){
} }
} }
} }
def parseBuildComponents( def text){
def components = []
"${text}".splitEachLine(',') { columns ->
if (columns[0].startsWith('#') || columns[0].startsWith('GroupID'))
return
components.add([
name : columns[1],
version : columns[2],
gitRepo : columns[3],
commitID: columns[4]
]
)
}
return components
}