Use a script block to skip the clean up of the repos if resumed.

This commit is contained in:
Manuele Simi 2020-01-13 17:29:00 +01:00
parent 6d12c91f49
commit 9734f1d9f2
1 changed files with 21 additions and 18 deletions

39
Jenkinsfile vendored
View File

@ -165,28 +165,31 @@ pipeline {
}
stage('initialize local repository') {
steps {
script {
if (resume) {
sh '''
echo "REMOVE_LOCAL_REPO: ${REMOVE_LOCAL_REPO}"
echo "CLEANUP_GCUBE_REPO: ${CLEANUP_GCUBE_REPO}"
if [ "$CLEANUP_GCUBE_REPO" = "true" ]; then
echo "Remove gCube artifacts from local repository"
rm -rf $MAVEN_LOCAL_REPO/org/gcube
fi
if [ "$REMOVE_LOCAL_REPO" = "true" ]; then
echo "Create a fresh local repository"
rm -rf $MAVEN_LOCAL_REPO
mkdir -p $MAVEN_LOCAL_REPO
fi
'''
}
}
sh '''
echo "RESUME_FROM: ${RESUME_FROM}"
if [ -z "$RESUME_FROM" ]; then
echo "REMOVE_LOCAL_REPO: ${REMOVE_LOCAL_REPO}"
echo "CLEANUP_GCUBE_REPO: ${CLEANUP_GCUBE_REPO}"
if [ "$CLEANUP_GCUBE_REPO" = "true" ]; then
echo "Remove gCube artifacts from local repository"
rm -rf $MAVEN_LOCAL_REPO/org/gcube
fi
if [ "$REMOVE_LOCAL_REPO" = "true" ]; then
echo "Create a fresh local repository"
rm -rf $MAVEN_LOCAL_REPO
mkdir -p $MAVEN_LOCAL_REPO
fi
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 and settings"
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 and settings"
'''
}
}
// the maven-parent needs to be built (once) at each execution
stage('build maven-parent') {
steps {