New boolean parameter to choose if the local repo must be wiped out or not.

This commit is contained in:
Manuele Simi 2019-10-11 08:52:48 -04:00
parent eb68c86eb0
commit f9035789e8
1 changed files with 11 additions and 4 deletions

15
Jenkinsfile vendored
View File

@ -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"
'''
}
}