Increase memory and add Maven retry for stability

This commit is contained in:
Yuxin Deng 2025-11-23 17:07:12 -05:00
parent cee599eb0e
commit 17c706a192
2 changed files with 15 additions and 4 deletions

View file

@ -6,6 +6,18 @@ RUN apt-get update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Configure Maven with retry settings
RUN mkdir -p /root/.m2 && \
echo '<?xml version="1.0" encoding="UTF-8"?>' > /root/.m2/settings.xml && \
echo '<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"' >> /root/.m2/settings.xml && \
echo ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' >> /root/.m2/settings.xml && \
echo ' xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0' >> /root/.m2/settings.xml && \
echo ' https://maven.apache.org/xsd/settings-1.0.0.xsd">' >> /root/.m2/settings.xml && \
echo ' <localRepository>/root/.m2/repository</localRepository>' >> /root/.m2/settings.xml && \
echo '</settings>' >> /root/.m2/settings.xml
ENV MAVEN_OPTS="-Xmx2048m -Dmaven.wagon.http.retryHandler.count=3"
WORKDIR /workspace
# Maven will be provided by the project's mvnw wrapper

7
Jenkinsfile vendored
View file

@ -7,10 +7,10 @@ pipeline {
}
environment {
MAVEN_OPTS = '-Xmx1024m'
MAVEN_OPTS = '-Xmx2048m'
PROJECT_NAME = 'spring-petclinic'
SONAR_PROJECT_KEY = 'spring-petclinic'
DOCKER_ARGS = '-v /var/run/docker.sock:/var/run/docker.sock --network spring-petclinic_devops-net'
DOCKER_ARGS = '-v /var/run/docker.sock:/var/run/docker.sock --network spring-petclinic_devops-net --memory=4g'
}
stages {
@ -89,8 +89,7 @@ pipeline {
echo 'Running SonarQube analysis...'
withSonarQubeEnv('SonarQubeServer') {
sh """
./mvnw clean verify sonar:sonar \
-DskipTests \
./mvnw sonar:sonar \
-Dsonar.projectKey=${SONAR_PROJECT_KEY} \
-Dsonar.projectName=${PROJECT_NAME} \
-Dsonar.projectVersion=${BUILD_NUMBER}