feature/22849 #2

Merged
roberto.cirillo merged 16 commits from feature/22849 into master 2022-03-07 16:28:47 +01:00
1 changed files with 13 additions and 5 deletions
Showing only changes of commit 49d307d1b3 - Show all commits

18
Jenkinsfile vendored
View File

@ -11,6 +11,7 @@ if (params.Type == 'SNAPSHOT-DRY-RUN') {
options = '' options = ''
maven_local_repo_path = "local-snapshots" maven_local_repo_path = "local-snapshots"
maven_settings_file = "jenkins-snapshots-dry-run-settings.xml" maven_settings_file = "jenkins-snapshots-dry-run-settings.xml"
maven_activation_property="";
maven_parent_file = "jenkins-snapshots-dry-run-settings.xml" maven_parent_file = "jenkins-snapshots-dry-run-settings.xml"
} }
if (params.Type == 'SNAPSHOT') { if (params.Type == 'SNAPSHOT') {
@ -18,6 +19,7 @@ if (params.Type == 'SNAPSHOT') {
options = '' options = ''
maven_local_repo_path = "local-snapshots" maven_local_repo_path = "local-snapshots"
maven_settings_file = "jenkins-snapshots-settings.xml" maven_settings_file = "jenkins-snapshots-settings.xml"
maven_activation_property="";
maven_parent_file = "jenkins-snapshots-dry-run-settings.xml" maven_parent_file = "jenkins-snapshots-dry-run-settings.xml"
} }
if (params.Type == 'RELEASE-DRY-RUN') { if (params.Type == 'RELEASE-DRY-RUN') {
@ -25,6 +27,7 @@ if (params.Type == 'RELEASE-DRY-RUN') {
options = '' options = ''
maven_local_repo_path = "local-releases" maven_local_repo_path = "local-releases"
maven_settings_file = "jenkins-releases-dry-run-settings.xml" maven_settings_file = "jenkins-releases-dry-run-settings.xml"
maven_activation_property="-Djenkins-releases=true";
maven_parent_file = "jenkins-releases-dry-run-settings.xml" maven_parent_file = "jenkins-releases-dry-run-settings.xml"
} }
if (params.Type == 'STAGING') { if (params.Type == 'STAGING') {
@ -32,6 +35,7 @@ if (params.Type == 'STAGING') {
options = '' options = ''
maven_local_repo_path = "local-staging" maven_local_repo_path = "local-staging"
maven_settings_file = "jenkins-staging-settings.xml" maven_settings_file = "jenkins-staging-settings.xml"
maven_activation_property="-Djenkins-staging=true";
maven_parent_file = "jenkins-staging-dry-run-settings.xml" maven_parent_file = "jenkins-staging-dry-run-settings.xml"
} }
if (params.Type == 'RELEASE') { if (params.Type == 'RELEASE') {
@ -39,10 +43,11 @@ if (params.Type == 'RELEASE') {
options = '' options = ''
maven_local_repo_path = "local-releases" maven_local_repo_path = "local-releases"
maven_settings_file = "jenkins-releases-settings.xml" maven_settings_file = "jenkins-releases-settings.xml"
maven_activation_property="-Djenkins-releases=true";
maven_parent_file = "jenkins-releases-dry-run-settings.xml" maven_parent_file = "jenkins-releases-dry-run-settings.xml"
} }
echo "Use settings file at ${maven_settings_file}" echo "Use settings file at ${maven_settings_file} with the following activation property: ${maven_activation_property}"
echo "Use local repo at ${maven_local_repo_path}" echo "Use local repo at ${maven_local_repo_path}"
echo "Release number: ${params.gCube_release_version}" echo "Release number: ${params.gCube_release_version}"
echo "Clean up gcube local artifacts? ${params.cleanup_gcube_artifacts}" echo "Clean up gcube local artifacts? ${params.cleanup_gcube_artifacts}"
@ -80,7 +85,9 @@ pipeline {
// see https://jenkins.io/doc/book/pipeline/syntax/#agent // see https://jenkins.io/doc/book/pipeline/syntax/#agent
agent { agent {
label 'CD' // label 'CD'
// just for test I'm going to use the following label
label 'CD-test'
} }
// see https://jenkins.io/doc/book/pipeline/syntax/#environment // see https://jenkins.io/doc/book/pipeline/syntax/#environment
@ -90,6 +97,7 @@ pipeline {
MAVEN_OPTS = "${params.build_options}" MAVEN_OPTS = "${params.build_options}"
AGENT_ROOT_FOLDER = "${agent_root_folder}" AGENT_ROOT_FOLDER = "${agent_root_folder}"
MAVEN_SETTINGS_FILE = "${maven_settings_file}" MAVEN_SETTINGS_FILE = "${maven_settings_file}"
MAVEN_ACTIVATION_PROPERTY = "${maven_activation_property}"
MAVEN_PARENT_FILE = "${maven_parent_file}" MAVEN_PARENT_FILE = "${maven_parent_file}"
MAVEN_LOCAL_REPO = "${agent_root_folder}/${maven_local_repo_path}" MAVEN_LOCAL_REPO = "${agent_root_folder}/${maven_local_repo_path}"
CLEANUP_GCUBE_REPO = "${params.cleanup_gcube_artifacts}" CLEANUP_GCUBE_REPO = "${params.cleanup_gcube_artifacts}"
@ -217,7 +225,7 @@ pipeline {
jsonConfig.gCube_release.Components.each { group_name, component_list -> jsonConfig.gCube_release.Components.each { group_name, component_list ->
stage("build ${group_name} components") { stage("build ${group_name} components") {
buildComponents items: component_list?.collect { "${it.name}" }, buildComponents items: component_list?.collect { "${it.name}" },
"${maven_settings_file}", "${maven_local_repo_path}", jobs "${maven_settings_file}", "${maven_activation_property}", "${maven_local_repo_path}", jobs
echo "Done with ${group_name} components" echo "Done with ${group_name} components"
} }
} }
@ -280,7 +288,7 @@ pipeline {
} }
} }
def buildComponents(args, maven_settings_file, maven_local_repo_path, jobs) { def buildComponents(args, maven_settings_file, maven_activation_property, maven_local_repo_path, jobs) {
if (args.items) { if (args.items) {
parallel args.items?.collectEntries { name -> parallel args.items?.collectEntries { name ->
["${name}": { ["${name}": {
@ -291,7 +299,7 @@ def buildComponents(args, maven_settings_file, maven_local_repo_path, jobs) {
sh "echo -e ${name},SUCCESS >> ${agent_root_folder}/build_jobs.${env.BUILD_NUMBER}.csv" sh "echo -e ${name},SUCCESS >> ${agent_root_folder}/build_jobs.${env.BUILD_NUMBER}.csv"
} else { } else {
def gjob = build(job: name, wait: true, propagate: true, def gjob = build(job: name, wait: true, propagate: true,
parameters: [[$class: 'StringParameterValue', name: 'gcube_settings', value: "${maven_settings_file}"], parameters: [[$class: 'StringParameterValue', name: 'gcube_settings', value: "${maven_settings_file} ${maven_activation_property}"],
[$class: 'StringParameterValue', name: 'local_repo', value: "${maven_local_repo_path}"], [$class: 'StringParameterValue', name: 'local_repo', value: "${maven_local_repo_path}"],
[$class: 'LabelParameterValue', name: 'exec_label', label: "CD", nodeEligibility: [$class: 'AllNodeEligibility']] [$class: 'LabelParameterValue', name: 'exec_label', label: "CD", nodeEligibility: [$class: 'AllNodeEligibility']]
]) ])