small changes

This commit is contained in:
Roberto Cirillo 2023-06-15 11:27:17 +02:00
parent eacc8c2d97
commit b0e4dd25be
1 changed files with 60 additions and 44 deletions

104
Jenkinsfile vendored
View File

@ -270,16 +270,9 @@ pipeline {
} }
} }
//launch ansible deploy
def deploy(String service, String version, String host){ /* CHECKUP METHODS */
def now = new Date();
println("Going to deploy the service "+service+" with version: "+version+" on target: "+host);
def statusCode = sh( script: "cd $ANSIBLE_ROOT_FOLDER;./deployService.sh $service $version $host;", returnStdout: true);
sh("""
echo " last exit code \$?";
""")
println("Deploy ended with status: "+statusCode);
}
//Implement a new method in order to check the input parameters //Implement a new method in order to check the input parameters
def checkup(String service, String version, String host){ def checkup(String service, String version, String host){
@ -292,16 +285,6 @@ def checkup(String service, String version, String host){
""") """)
} }
//launch ansible deploy
def deployRelease(String service, String version, String smartgears){
def now = new Date();
println("Going to deploy the service "+service+" with version: "+version+" on preproduction ");
def statusCode = sh( script: "cd $ANSIBLE_ROOT_FOLDER;git pull;./deployPreprodService.sh $service $version $smartgears ;", returnStdout: true);
sh("""
echo " last exit code \$?";
""")
println("Deploy ended with status: "+statusCode);
}
//Implement a new method in order to check the input parameters //Implement a new method in order to check the input parameters
def checkupRelease(String service, String version){ def checkupRelease(String service, String version){
@ -313,6 +296,10 @@ def checkupRelease(String service, String version){
esac esac
""") """)
} }
/* DEPLOY METHODS*/
//parse all csv files found in the local folder and deploy the components defined inside //parse all csv files found in the local folder and deploy the components defined inside
def parseDeployPendingJobs( def deployFolder){ def parseDeployPendingJobs( def deployFolder){
println ("searching files in folder ${deployFolder}"); println ("searching files in folder ${deployFolder}");
@ -347,32 +334,23 @@ def deployJobs(def serviceList){
} }
} }
//Deploy only release components. All the component are passed as: componentName,componentVersion
def deployReleaseJobs(def serviceList, String smartgears){
if (serviceList){
println("Going to deploy release components");
for (def record : serviceList) {
service=record.split(",");
stage(service[0]){
println("Processing RELEASE deploy: service "+service[ 0 ]+" with version "+service[ 1 ]+" and SG "+smartgears)
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
checkupRelease(service[0], service[ 1 ]);
if (smartgears)
deployRelease(service[0], service[ 1 ], smartgears);
else
deployRelease(service[0], service[ 1 ], '');
}
}
}
}else{
println("Release components not found. Skip this stage");
}
//Run ansible deploy
def deploy(String service, String version, String host){
def now = new Date();
println("Going to deploy the service "+service+" with version: "+version+" on target: "+host);
def statusCode = sh( script: "cd $ANSIBLE_ROOT_FOLDER;./deployService.sh $service $version $host;", returnStdout: true);
sh("""
echo " last exit code \$?";
""")
println("Deploy ended with status: "+statusCode);
} }
// collects all the components defined inside one or more yaml categories matching categoryList
/* DEPLOY RELEASE METHODS*/
// collects all the components defined inside one or more yaml categories matching categoryList and invoke the deploy
def deployRelease(def categoryList, def yaml){ def deployRelease(def categoryList, def yaml){
def releaseList = [] def releaseList = []
def portlets = [] def portlets = []
@ -403,3 +381,41 @@ def deployRelease(def categoryList, def yaml){
} }
deployReleaseJobs(releaseList, smartgears); deployReleaseJobs(releaseList, smartgears);
} }
//Deploy only release components, starting from a servicelist. All the component are passed as: componentName,componentVersion
def deployReleaseJobs(def serviceList, String smartgears){
if (serviceList){
println("Going to deploy release components");
for (def record : serviceList) {
service=record.split(",");
stage(service[0]){
println("Processing RELEASE deploy: service "+service[ 0 ]+" with version "+service[ 1 ]+" and SG "+smartgears)
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') {
checkupRelease(service[0], service[ 1 ]);
if (smartgears)
deployReleaseJob(service[0], service[ 1 ], smartgears);
else
deployReleaseJob(service[0], service[ 1 ], '');
}
}
}
}else{
println("Release components not found. Skip this stage");
}
}
//Run ansible deploy related to a single service
def deployReleaseJob(String service, String version, String smartgears){
def now = new Date();
println("Going to deploy the service "+service+" with version: "+version+" on preproduction ");
def statusCode = sh( script: "cd $ANSIBLE_ROOT_FOLDER;git pull;./deployPreprodService.sh $service $version $smartgears ;", returnStdout: true);
sh("""
echo " last exit code \$?";
""")
println("Deploy ended with status: "+statusCode);
}