From 95786ffbfd1c1190bf146d8e924b3628d0a982dd Mon Sep 17 00:00:00 2001 From: Lihan Date: Sun, 28 Jul 2024 00:48:05 -0400 Subject: [PATCH] test --- Dockerfile | 8 +++++--- Jenkinsfile | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2a1eed127..213f27453 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,13 +11,15 @@ COPY mvnw pom.xml ./ # Copy the project source code COPY src ./src +# Introduce an ARG to act as a cache breaker +ARG CACHEBUSTER=unknown + # Package the application RUN ./mvnw clean package -Dmaven.test.skip=true RUN ls -alh /app/target/ -# Copy the JAR file to the app directory -WORKDIR /app -COPY /var/jenkins_home/workspace/ing-petclinic_use_docker_compose/target/spring-petclinic-3.3.0-SNAPSHOT.jar /app/app.jar +# Move the JAR file to the app directory (update this if necessary based on actual JAR names) +COPY target/*.jar /app/app.jar # Run the jar file CMD ["java", "-jar", "app.jar"] diff --git a/Jenkinsfile b/Jenkinsfile index 5198b7d29..fb309ad73 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,8 @@ pipeline { steps { script { echo "Building Docker Image..." - def dockerImage = docker.build("spring-petclinic", "--no-cache .") + // Add a cache buster to force no-cache on certain steps + def dockerImage = docker.build("spring-petclinic", "--build-arg CACHEBUSTER=$(date +%s) --no-cache .") echo "Docker Image built: ${dockerImage.id}" // Store the Docker image ID in the environment if needed across stages env.DOCKER_IMAGE_ID = dockerImage.id