Compare commits

...

19 Commits

Author SHA1 Message Date
Roberto Cirillo 5e84d57f91 Update Jenkinsfile
change email address to jenkinsbuilds@d4science.org
2024-11-28 12:25:26 +01:00
Roberto Cirillo 545ec46752 remove hardcoded dry-run 2024-11-11 11:16:06 +01:00
Roberto Cirillo 6a162840a4 hardcoded dryrun mode 2024-11-11 10:01:50 +01:00
Roberto Cirillo 4a89d6b448 Update README.md
fix readme
2024-11-07 10:01:16 +01:00
Roberto Cirillo d678d87ec8 fix checkup method exit condition 2024-11-05 15:06:20 +01:00
Roberto Cirillo 78904c0793 fix checkup method exit condition 2024-11-05 14:43:42 +01:00
Roberto Cirillo fea4741152 Merge pull request 'bug/28263' (#9) from bug/28263 into master
Reviewed-on: #9
2024-11-04 10:02:09 +01:00
Roberto Cirillo c9af197c68 split catcherror in order to manage differents cases 2024-10-30 15:46:28 +01:00
Roberto Cirillo 4ab3535e90 removed catch error inside deployJobs 2024-10-30 14:55:35 +01:00
Roberto Cirillo ad9f9382fb add status check on release deploy groovy script 2024-10-30 12:39:33 +01:00
Roberto Cirillo 5bbf75f4fd small change 2024-10-30 11:45:39 +01:00
Roberto Cirillo 8ae9a74ff0 small change 2024-10-30 11:43:54 +01:00
Roberto Cirillo cf0ea75460 add exit to deploy script 2024-10-30 11:31:43 +01:00
Roberto Cirillo 4728bd16b9 small fix 2024-10-30 10:44:48 +01:00
Roberto Cirillo ecc8b71cbe add dir function for testing 2024-10-30 10:41:26 +01:00
Roberto Cirillo ceaa196895 small fix 2024-10-30 10:33:40 +01:00
Roberto Cirillo ec7ae82e9b fix print message 2024-10-30 10:30:49 +01:00
Roberto Cirillo d56d1a693e add check on statusCode 2024-10-30 10:18:15 +01:00
Roberto Cirillo dbee8ad96c Merge pull request 'set ANSIBLE_ROOT_FOLDER value to d4science-smartgears-services/' (#8) from feature/27892 into master
Reviewed-on: #8
2024-09-18 15:48:02 +02:00
2 changed files with 53 additions and 19 deletions

48
Jenkinsfile vendored
View File

@ -82,7 +82,7 @@ pipeline {
//URL to the YAML file. Used alternatively to RELEASE_JOB //URL to the YAML file. Used alternatively to RELEASE_JOB
RELEASE_URL= "${params.RELEASE_URL}" RELEASE_URL= "${params.RELEASE_URL}"
// username of ReleaseManager. Used for limiting the preproduction deployments // username of ReleaseManager. Used for limiting the preproduction deployments
RELEASE_MANAGER_USER='roberto.cirillo' RELEASE_MANAGER_USER='giancarlo.panichi'
// name of Smartgears distribution group, defined in the yaml file ( only for release deployments) // name of Smartgears distribution group, defined in the yaml file ( only for release deployments)
DISTRIBUTION_CATEGORY='Distribution' DISTRIBUTION_CATEGORY='Distribution'
// name of Portlets group, defined in the yaml file ( only for release deployments) // name of Portlets group, defined in the yaml file ( only for release deployments)
@ -203,8 +203,13 @@ pipeline {
echo '\033[31;1;4mNew upstream deploy ongoing\033[0m' echo '\033[31;1;4mNew upstream deploy ongoing\033[0m'
echo "Cron build disabled. Component: ${params.TRIGGER_JOB} - ${params.TRIGGER_VERSION}" echo "Cron build disabled. Component: ${params.TRIGGER_JOB} - ${params.TRIGGER_VERSION}"
ansiColor('xterm') { ansiColor('xterm') {
catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') {
checkup("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}"); checkup("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}");
}
if (currentBuild.result == "UNSTABLE") {
return;
}
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
deploy("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}", "${params.TRIGGER_FOO}"); deploy("${params.TRIGGER_JOB}", "${params.TRIGGER_VERSION}", "${params.TRIGGER_HOST}", "${params.TRIGGER_FOO}");
} }
} }
@ -262,14 +267,14 @@ pipeline {
echo 'The deploy pipeline worked!' echo 'The deploy pipeline worked!'
emailext attachLog: true,//attachmentsPattern: "**/${ACTION_DEPLOY_FILE}.csv", emailext attachLog: true,//attachmentsPattern: "**/${ACTION_DEPLOY_FILE}.csv",
to: 'roberto.cirillo@isti.cnr.it', to: 'jenkinsbuilds@d4science.org',
subject: "[Jenkins-gCubeDeployer] Deploy report", subject: "[Jenkins-gCubeDeployer] Deploy report",
body: "${currentBuild.fullDisplayName}. Build time: ${currentBuild.durationString}. See ${env.BUILD_URL}. " body: "${currentBuild.fullDisplayName}. Build time: ${currentBuild.durationString}. See ${env.BUILD_URL}. "
} }
failure { failure {
echo 'The deploy pipeline has failed' echo 'The deploy pipeline has failed'
emailext attachLog: true, emailext attachLog: true,
to: 'roberto.cirillo@isti.cnr.it', to: 'jenkinsbuilds@d4science.org',
subject: "[Jenkins-gCubeDeployer] deploy ${currentBuild.fullDisplayName} failed", subject: "[Jenkins-gCubeDeployer] deploy ${currentBuild.fullDisplayName} failed",
body: "Something is wrong with ${env.BUILD_URL}" body: "Something is wrong with ${env.BUILD_URL}"
} }
@ -334,6 +339,11 @@ def deployJobs(def serviceList){
println("Processing deploy: "+service[ 0 ]) println("Processing deploy: "+service[ 0 ])
catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') { catchError(buildResult: 'UNSTABLE', stageResult: 'UNSTABLE') {
checkup(service[0], service[ 1 ], service[2]); checkup(service[0], service[ 1 ], service[2]);
}
if (currentBuild.result == "UNSTABLE") {
return;
}
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
deploy(service[0], service[ 1 ], service[2]); deploy(service[0], service[ 1 ], service[2]);
} }
} }
@ -345,11 +355,23 @@ def deployJobs(def serviceList){
def deploy(String service, String version, String host, String foo){ def deploy(String service, String version, String host, String foo){
def now = new Date(); def now = new Date();
println("Going to deploy the service "+service+" with version: "+version+" on target: "+host+" with argument: "+foo); println("Going to deploy the service "+service+" with version: "+version+" on target: "+host+" with argument: "+foo);
def statusCode = sh( script: "cd ${ANSIBLE_ROOT_FOLDER}/CD;./deployService.sh $service $version $host $foo;", returnStdout: true); dir("${ANSIBLE_ROOT_FOLDER}/CD/"){
sh("""
git pull;
""")
def statusCode = sh( script: "./deployService.sh $service $version $host $foo;", returnStatus: true);
sh(""" sh("""
echo " last exit code \$?"; echo " last exit code \$?";
""") """)
println("Deploy ended with status: "+statusCode); println("Deploy statusCode value: "+statusCode);
if (statusCode != 0){
currentBuild.result = 'FAILURE'
sh("""
exit $statusCode;
""")
}
}
} }
@ -422,9 +444,21 @@ def deployReleaseJobs(def serviceList, String smartgears, boolean isPortlet){
def deployReleaseJob(String service, String version, String smartgears){ def deployReleaseJob(String service, String version, String smartgears){
def now = new Date(); def now = new Date();
println("Going to deploy "+service+" "+version+" on preproduction "); println("Going to deploy "+service+" "+version+" on preproduction ");
def statusCode = sh( script: "cd ${ANSIBLE_ROOT_FOLDER}/CD;git pull;./deployPreprodService.sh $service $version $smartgears ;", returnStdout: true); dir("${ANSIBLE_ROOT_FOLDER}/CD/"){
sh("""
git pull;
""")
def statusCode = sh( script: "./deployPreprodService.sh $service $version $smartgears ;", returnStatus: true);
sh(""" sh("""
echo " last exit code \$?"; echo " last exit code \$?";
""") """)
println("Deploy ended with status: "+statusCode); println("Deploy ended with status: "+statusCode);
if (statusCode != 0){
currentBuild.result = 'FAILURE'
sh("""
exit $statusCode;
""")
}
}
} }

View File

@ -20,7 +20,7 @@ Jenkins Pipeline script to manage one or more gCube components deployment
The variables below must be specified as environment variables on the agent where the deployments will be executed: The variables below must be specified as environment variables on the agent where the deployments will be executed:
* IS_SCHEDULED (True | False): if true all the deployment requests will be performed periodically as specified by cron * IS_SCHEDULED (True | False): if true all the deployment requests will be performed periodically as specified by cron
* ENVIRONMENT: ( DEV | PREPROD | PROD) Indicates the target environment where will be deployed all the artifacts * ENVIRONMENT: ( DEV | PREPROD | PROD) Indicates the target environment where will be deployed all the artifacts
* DEPLOY_CATEGORY: (Related to release build) one or more Component group on yaml file where search the components to deploy * DEPLOY_CATEGORY: (Related to release build) one or more Component group (separated by commas) on yaml file where search the components to deploy
* CD: (Continuous Deployment: True | False) if True the remote deploy will be performed * CD: (Continuous Deployment: True | False) if True the remote deploy will be performed
## References ## References