fix conflicts

Merge branch 'feature/23745'
This commit is contained in:
Roberto Cirillo 2022-10-05 10:31:10 +02:00
commit 47aa7111e2
1 changed files with 40 additions and 33 deletions

73
Jenkinsfile vendored
View File

@ -81,41 +81,14 @@ pipeline {
allOf{ allOf{
triggeredBy 'TimerTrigger' triggeredBy 'TimerTrigger'
// maybe we can add a new condition in order to consider the manual execution of this pipeline // maybe we can add a new condition in order to consider the manual execution of this pipeline
environment name: 'IS_CRON', value: 'True' environment name: 'IS_SCHEDULED', value: 'True'
} }
} }
steps { steps {
echo 'Cron build enabled. Deploy from system ongoing' echo 'Cron build enabled. Deploy from system ongoing'
script { script {
def deployFolder="CD-${env.BUILD_NUMBER}"; def deployFolder="CD-${env.BUILD_NUMBER}";
println ("searching files in folder ${deployFolder}"); deployPendingJobs(deployFolder);
def files = findFiles(glob: "${deployFolder}/*.csv")
if (files == null){
println ("Nothing to do");
}else{
def serviceList = []
for (def file : files){
def records = readCSV file: "${file.path}"
for (def record : records) {
println("Processing record: "+record)
if(!serviceList.contains(record.get(0))){
stage(record.get(0)){
println "Deploy on going of component: ${record.get(0)}"
catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') {
checkup(record.get(0), record.get(1), record.get(2));
deploy(record.get(0), record.get(1), record.get(2));
}
}
serviceList << record.get(0)
}else{
echo "${record.get(0)} already deployed. Deployment skipped."
}
}
sh "rm ${file.path}"
}
sh "rm -Rf ${deployFolder}"
}
} }
@ -126,7 +99,7 @@ pipeline {
anyOf{ anyOf{
allOf{ allOf{
triggeredBy 'TimerTrigger' triggeredBy 'TimerTrigger'
environment name: 'IS_CRON', value: 'False' environment name: 'IS_SCHEDULED', value: 'False'
} }
} }
@ -137,7 +110,7 @@ pipeline {
} }
stage('New pending deploy ') { stage('New pending deploy ') {
when{ when{
environment name: 'IS_CRON', value: 'True' environment name: 'IS_SCHEDULED', value: 'True'
anyOf{ anyOf{
triggeredBy 'BuildUpstreamCause' triggeredBy 'BuildUpstreamCause'
triggeredBy 'UpstreamCause' triggeredBy 'UpstreamCause'
@ -164,7 +137,7 @@ pipeline {
} }
stage('Deploy from job ') { stage('Deploy from job ') {
when{ when{
environment name: 'IS_CRON', value: 'False'; environment name: 'IS_SCHEDULED', value: 'False';
expression { expression {
env.TRIGGER_CD.toBoolean() env.TRIGGER_CD.toBoolean()
} }
@ -187,7 +160,7 @@ pipeline {
stage('Deploy manually ') { stage('Deploy manually ') {
when{ when{
allOf{ allOf{
environment name: 'IS_CRON', value: 'False'; environment name: 'IS_SCHEDULED', value: 'False';
triggeredBy 'UserIdCause' triggeredBy 'UserIdCause'
} }
} }
@ -251,3 +224,37 @@ def checkup(String service, String version, String host){
esac esac
""") """)
} }
//parse all csv files found in the local folder and deploy the components defined inside
def deployPendingJobs( def deployFolder){
println ("searching files in folder ${deployFolder}");
def files = findFiles(glob: "${deployFolder}/*.csv")
if (files == null){
println ("Nothing to do");
}else{
def serviceList = []
for (def file : files){
def records = readCSV file: "${file.path}"
for (def record : records) {
println("Processing record: "+record)
if(!serviceList.contains(record.get(0))){
stage(record.get(0)){
println "Deploy on going of component: ${record.get(0)}"
catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') {
checkup(record.get(0), record.get(1), record.get(2));
deploy(record.get(0), record.get(1), record.get(2));
}
}
serviceList << record.get(0)
}else{
echo "${record.get(0)} already deployed. Deployment skipped."
}
}
sh "rm ${file.path}"
}
sh "rm -Rf ${deployFolder}"
}
}