From f9035789e8437cf1178312654bda8ba344a06613 Mon Sep 17 00:00:00 2001 From: Manuele Simi Date: Fri, 11 Oct 2019 08:52:48 -0400 Subject: [PATCH] New boolean parameter to choose if the local repo must be wiped out or not. --- Jenkinsfile | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 92f2a90..2627df0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -75,6 +75,7 @@ pipeline { MAVEN_LOCAL_REPO = "${agent_root_folder}/${maven_local_repo_path}" GCUBE_RELEASE_NUMBER = "${params.gCube_release_version}" PIPELINE_BUILD_NUMBER = "${env.BUILD_NUMBER}" + CLEANUP_LOCAL_REPO = "${params.cleanup_local_repo}" } // see https://jenkins.io/doc/book/pipeline/syntax/#parameters @@ -86,6 +87,10 @@ pipeline { string(name: 'gCube_release_version', defaultValue: 'x.y.z', description: 'The number of the gCube release to build. Sample values: 4.14, 4.15, etc.') + + booleanParam(name: 'cleanup_local_repo', + defaultValue: true, + description: 'Whether the local maven repository needs to be wiped out before the builds.') } //see https://jenkins.io/doc/book/pipeline/syntax/#stages @@ -93,12 +98,14 @@ pipeline { stage('clean up before starting') { steps { sh ''' - echo "Create a fresh local repository" - rm -rf $MAVEN_LOCAL_REPO - mkdir -p $MAVEN_LOCAL_REPO + if [ "$CLEANUP_LOCAL_REPO" = "true" ]; then + echo "Create a fresh local repository" + rm -rf $MAVEN_LOCAL_REPO + mkdir -p $MAVEN_LOCAL_REPO + fi mv "${AGENT_ROOT_FOLDER}/settings.xml" "${AGENT_ROOT_FOLDER}/settings.${PIPELINE_BUILD_NUMBER}" cp "${AGENT_ROOT_FOLDER}/${MAVEN_SETTINGS_FILE}" "${AGENT_ROOT_FOLDER}/settings.xml" - echo "Done with local repository" + echo "Done with local repository and settings" ''' } }